2

I'm a newbie on tikz and wanted to draw some additional arrows on the Control Flow Graph (shown via thick arrows) using tikz. For some part of the graph I may want to show just the black thick arrow and for the other just the grey thick arrow along with the usual arrow. Appreciate if anyone can help.

Thanks,

Here is the code I have written so far....

\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{shapes,positioning}
\usetikzlibrary{arrows}

\usetikzlibrary{automata}

\begin{document}

\begin{figure}[H]
\centering
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,>=stealth',
every state/.style={draw=black!50,very thick,fill=black!10}]
\node[state,initial] (q0) {$q_0$};
\node[state] (q1) [above right=of q0] {$q_1$};
\node[state] (q2) [below right=of q0] {$q_2$};
\path[->] (q0) edge node [above left] {0} (q1)
edge node [below left] {1} (q2)
(q1) edge [loop above] node {0} ()
(q2) edge [loop below] node {1} ();
\end{tikzpicture}
\end{figure}

\end{document}

enter image description here

1
  • 1
    Welcome to TeX.Stackexchange! If you could show us what you have so far, I am sure we can help you adding additional arrows. – samcarter_is_at_topanswers.xyz Aug 27 '17 at 19:32
1

As you already loaded the arrows library, you could maybe use something like this:

\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,>=stealth',
    every state/.style={draw=black!50,very thick,fill=black!10},
    arrow/.style={single arrow,draw,fill=black!50,inner sep=1pt,minimum height=15pt,single arrow head extend=2pt,outer sep=3pt,sloped}]
  \node[state,initial] (q0) {$q_0$};
  \node[state] (q1) [above right=of q0] {$q_1$};
  \path[->] (q0) edge node [anchor=south,arrow] {} node [anchor=north,arrow,fill=black] {} (q1);
\end{tikzpicture}

Which should result in:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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