1

How to draw a MWE of a directed graph in Tikz using arrows and automata?

closed as too broad by TeXnician, Stefan Pinnow, Schweinebacke, Mico, Ruben Aug 14 '17 at 14:34

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    see examples in tikz & pgf manual, page 513. – Zarko Aug 14 '17 at 13:03
1
\documentclass[12pt,letterpaper]{report}
\usepackage{pgf, tikz}
\usetikzlibrary{arrows, automata}

\begin{document}

    \begin{tikzpicture}[
            > = stealth, % arrow head style
            shorten > = 1pt, % don't touch arrow head to node
            auto,
            node distance = 3cm, % distance between nodes
            semithick % line style
        ]

        \tikzstyle{every state}=[
            draw = black,
            thick,
            fill = white,
            minimum size = 4mm
        ]

        \node[state] (s) {$s$};
        \node[state] (v1) [above right of=s] {$v_1$};
        \node[state] (v2) [right of=s] {$v_2$};
        \node[state] (v3) [below right of=s] {$v_2$};
        \node[state] (t) [right of=v2] {$t$};

        \path[->] (s) edge node {18} (v1);
        \path[->] (s) edge node {1} (v2);
        \path[->] (s) edge node {1} (v3);
        \path[->] (v2) edge node {2} (v1);
        \path[->] (v3) edge node {1} (v2);
        \path[->] (v1) edge node {20} (t);

        \draw[red, dashed] (1, 2) -- (1, -2);
    \end{tikzpicture}

\end{document}

directed-graph

  • is this answer or only continuation of your question? – Zarko Aug 14 '17 at 13:03
  • it is an answer – Georges Aug 14 '17 at 13:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.