latex TikZ -- Graph specifications


Example

TikZ provides syntax similar to DOT which you can use to tighten up your graph drawing code considerably.

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{graphs,quotes,arrows.meta}

\begin{document}
  \begin{tikzpicture}
    \graph[nodes={draw,circle},edges={-{Stealth[]}}] {
      A -> ["1"] B, 
      A -> C,
      C -> B
    };
  \end{tikzpicture}
\end{document}

enter image description here

As you can see, you trade fine-grained control for easier syntax. The graphs library really shines when you specify more complicated graphs:

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{graphs,graphs.standard}

\begin{document}
  \begin{tikzpicture}
    \graph {
      A -> { subgraph I_n [V= {B,C,D}] } -> E 
    };
  \end{tikzpicture}
\end{document}

enter image description here

There are many more options and pre-defined graphs; see section 19 of the TikZ manual.