1

i have made the following transition diagram enter image description here

There are a few thinks i would like to do, on node 1,2,3 i would like the inner arrows to have no overlab, i looks silly, also if node 1 and 5 could be aligned, doesn't matter if 5 is moved down or 1 is moved up. I am still pretty new at tikz, but hope one of you kan help. Code below.

Thanks!

Steffen

\documentclass[a4paper,oneside,article]{memoir}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}[->,,>=stealth',shorten >=1pt,node distance=2cm,
thick,main node/.style={circle,draw,font=\sffamily\Large\bfseries}]

\node[main node] (1) {1};
\node[main node] (2) [below left of=1] {2};
\node[main node] (3) [below right of=1] {3};
\node[main node] (4) [right of=3] {4};
\node[main node] (5) [above of=4] {5};
\node[main node] (6) [right of=4] {6};

\path[every node/.style={font=\sffamily\small}]
(1) edge [bend right] node {} (2)
    edge [bend right] node {} (3)
    edge [loop above] node {} (1)
(2) edge [bend right] node {} (1)
    edge [bend left] node {} (3)
    edge [loop below] node {} (2)
(3) edge [bend right] node {} (1)
    edge [bend left] node {} (2)
    edge [loop below] node {} (3)
(4) edge [bend right] node {} (5)
    edge node {} (3)
    edge node {} (6)
    edge [loop below] node {} (4)
(5) edge [bend right] node {} (4)
    edge [loop above] node {} (5)
(6) edge [loop right] node {} (6)   
;
\end{tikzpicture}
\end{document}

1 Answer 1

3

Use arrows.meta instead of arrows (which is apparently deprecated anyway). The definition for stealth tip becomes >={stealth}.

In order for the arrows to avoid overlapping, edit the bend options by adding the degrees for the single arrows you want to affect. So for example bend right/left=15 works in this case.

Lastly, if you want to align two nodes on the x and the y axis, type \node (n) at (<node> -| <node>) {};, so in your case it becomes \node[main node] (5) at (1 -| 4) {5};.

Output

figure 1

Code

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}

\usetikzlibrary{arrows.meta}

\begin{document}
\begin{tikzpicture}[
    ->,
    >={Stealth[round]},
    shorten >=1pt,
    node distance=2cm,
    thick,
    main node/.style={circle,draw,font=\sffamily\Large\bfseries}]

\node[main node] (1) {1};
\node[main node] (2) [below left of=1] {2};
\node[main node] (3) [below right of=1] {3};
\node[main node] (4) [right of=3] {4};
\node[main node] (5) at (1 -| 4) {5};
\node[main node] (6) [right of=4] {6};

\path[every node/.style={font=\sffamily\small}]
(1) edge [bend right] node {} (2)
    edge [bend right=15] node {} (3)
    edge [loop above] node {} (1)
(2) edge [bend right=15] node {} (1)
    edge [bend left=15] node {} (3)
    edge [loop below] node {} (2)
(3) edge [bend right] node {} (1)
    edge [bend left] node {} (2)
    edge [loop below] node {} (3)
(4) edge [bend right] node {} (5)
    edge node {} (3)
    edge node {} (6)
    edge [loop below] node {} (4)
(5) edge [bend right] node {} (4)
    edge [loop above] node {} (5)
(6) edge [loop right] node {} (6);
\end{tikzpicture}
\end{document}
3
  • @SteffenHvid No problem! :D Happy to help. I changed the document class for this example, you should change it back. :)
    – Alenanno
    May 6, 2015 at 10:33
  • 1
    All arrow tips from arrows.meta are capitalized. So it should be >=Stealth. stealth would activate the old arrow tip without the functionality of the new library. (The old stealth' arrow tip is now Stealth[round].) May 6, 2015 at 11:47
  • @SteffenHvid See fixed arrow tips. :D
    – Alenanno
    May 6, 2015 at 11:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .