[Tex/LaTex] Graph into graph with arrows

arrowsgraphs

I'm using tikzpicture and I have some graphs, but I want some graphs with arrows. Is there any simple syntax change for that?

My Graph:

\begin{tikzpicture}[thick]
         \begin{scope}
           \draw (4,0) node[label=below:5] {};
...
         \end{scope}
         \draw 
...
         (4,4) -- (6,0);
\end{tikzpicture}

Best Answer

As Martin commented you can use [->] in the \draw command to add an arrow. Different arrow style can also be specified by using options such as: -stealth, -latex, etc.. Here are a few types:

enter image description here

See Section 23 Arrow Tip Library for a list of the various ones that are already available. Adding \usepgflibrary{arrows} to your preamble provides a large variety of built in arrows.

\documentclass[border=3pt]{standalone}
\usepackage{tikz}
\usepgflibrary{arrows}% for more options on arrows

\begin{document}
\begin{tikzpicture}[thick]
\draw [green, ->          ] (0,8.0) -- (1,8.0);
\draw [blue,  -stealth    ] (0,7.5) -- (1,7.5) node [right] {stealth};
\draw [red,   -latex      ] (0,7.0) -- (1,7.0) node [right] {latex};
\draw [cyan,  -to         ] (0,6.5) -- (1,6.5) node [right] {to};
\draw [brown, -triangle 60] (0,6.0) -- (1,6.0) node [right] {triangle 60};
\end{tikzpicture}
\end{document}

Since you included a scope in your example, it should be noted that you can also specify the arrow to be used for each line in a scope as well by adding that to the options to \begin{scope}. In the following all lines will have -stealth arrows. Adding - will disable the arrow for a particular line:

enter image description here

\documentclass[border=3pt]{standalone}
\usepackage{tikz}
\usepgflibrary{arrows}% for more options on arrows

\begin{document}
\begin{tikzpicture}[thick]
\begin{scope}[-stealth]
    \draw [blue   ] (0,7.5) -- (1,7.5) node [right] {stealth};;
    \draw [red,   ] (0,7.0) -- (1,7.0) node [right] {stealth};
    \draw [brown,-] (0,6.5) -- (1,6.5);
\end{scope}
\end{tikzpicture}
\end{document}
Related Question