2

I need to draw a path of arrow like this : The goal

I have try this code :

\documentclass[tikz, border=2mm]{standalone}
\begin{document}
    \begin{tikzpicture}[scale=2]
        \node[circle, draw=black] (A) at (0,0){A};
        \node[circle, draw=black] (B) at (1,0){B};
        \node[circle, draw=black] (C) at (2,0){C};
        \node[circle, draw=black] (D) at (3,0){D};
        \draw[->] (A) -- (B) -- (C) -- (D);
    \end{tikzpicture}
\end{document}

But i have something like that :

By the code

How to do that ?

EDIT : I change the post

Capt_
  • 145
  • 10

2 Answers2

4

Update : with the graphs library

The graphs library allows you to do this in a simple and concise way. See the section 19.2.2 Concept: Chain Groups in the pgfmanual screenshot

\documentclass[tikz, border=5mm]{standalone}
\usetikzlibrary {graphs}

\begin{document}

\tikz\graph[grow right=20mm,nodes={draw, circle,fill=cyan!30}] {A -> B -> C -> D};

\end{document}

First answer: with the chains library

The chains library allows you to do this. See section 48 Chains of the pgfmanual.

screenshot

\documentclass[tikz, border=2mm]{standalone}
 \usetikzlibrary {chains}

\begin{document} \begin{tikzpicture}[node distance=20mm, on grid, every node/.style=draw,circle,every join/.style=->] \begin{scope}[start chain] \node [draw,on chain,join] {A}; \node [draw,on chain,join] {B}; \node [draw,on chain,join] {C}; \node [draw,on chain,join] {D}; \end{scope} \end{tikzpicture}

\end{document}

AndréC
  • 24,137
2

Similar to that in @AndréC's answer (+1), but with a bit shorter code:

\documentclass[tikz, border=2mm]{standalone}
\usetikzlibrary{arrows.meta,
                chains}

\begin{document} \begin{tikzpicture}[ node distance = 20mm, on grid, start chain = going right, every node/.style = {circle, draw, on chain, join=by -{Straight Barb[scale=0.8]}} ] \node {A}; \node {B}; \node {C}; \node {D}; \end{tikzpicture}

\end{document}

enter image description here

Zarko
  • 296,517