1
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,
                calc, chains, 
                positioning}
         \begin{document}       
                \begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=4cm,
                thick,main node/.style={circle,draw,font=\Large\bfseries,
    align=center,
    execute at begin node=\setlength{\baselineskip}{2em}}]

  \node[main node] (1) {1 \\ s};
  \node[main node] (2) [below left of=1] {2};
  \node[main node] (3) [below right of=1] {3};

  \path
    (1) edge [loop above] node {0.6} (1)
        edge [bend right] node {0.4} (2)
    (2) edge node [below]{1.0} (1)
    (3) edge [loop below] node {0.8} (3)
        edge node[right] {0.1} (1)
        edge node[below] {0.1} (2);      
\end{tikzpicture}
\end{document}

I see the loop on node 1\\s is bigger then the others but how I can make it same size as the smaller ones?

enter image description here

1 Answer 1

1

The size of the loop adjusts to the size of the node it is attached to. IMHO it is esthetically more pleasing if all nodes have the same size.

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,calc,positioning}
\begin{document}       
\begin{tikzpicture}[->,>=Stealth,shorten >=1pt,auto,node distance=4cm,
    thick,main node/.style={circle,draw,font=\Large\bfseries,
    align=center,
    execute at begin node=\setlength{\baselineskip}{2em},
    },auto]

  \path node[main node] (1) {1 \\ s}
   let \p1=($(1.north)-(1.south)$) in
   node[main node,minimum size=\y1] (2) [below left=of 1] {2}
   node[main node,minimum size=\y1] (3) [below right=of 1] {3};

  \path
    (1) edge [loop above] node {0.6} (1)
        edge [bend right] node {0.4} (2)
    (2) edge node [below right]{1.0} (1)
    (3) edge [loop below] node {0.8} (3)
        edge node[above right] {0.1} (1)
        edge node[below] {0.1} (2);      
\end{tikzpicture}
\end{document}

enter image description here

You can also just increase the looseness.

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,calc,positioning}
\begin{document}       
\begin{tikzpicture}[->,>=Stealth,shorten >=1pt,auto,node distance=4cm,
    thick,main node/.style={circle,draw,font=\Large\bfseries,
    align=center,
    execute at begin node=\setlength{\baselineskip}{2em},
    },auto]

  \path node[main node] (1) {1 \\ s}
   node[main node] (2) [below left=of 1] {2}
   node[main node] (3) [below right=of 1] {3};

  \path
    (1) edge [loop above] node {0.6} (1)
        edge [bend right] node {0.4} (2)
    (2) edge node [below right]{1.0} (1)
    (3) edge [loop below,looseness=22] node {0.8} (3)
        edge node[above right] {0.1} (1)
        edge node[below] {0.1} (2);      
\end{tikzpicture}
\end{document}

enter image description here

Or decrease the looseness of the larger loop.

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,calc,positioning}
\begin{document}       
\begin{tikzpicture}[->,>=Stealth,shorten >=1pt,auto,node distance=4cm,
    thick,main node/.style={circle,draw,font=\Large\bfseries,
    align=center,
    execute at begin node=\setlength{\baselineskip}{2em},
    },auto]

  \path node[main node] (1) {1 \\ s}
   node[main node] (2) [below left=of 1] {2}
   node[main node] (3) [below right=of 1] {3};

  \path
    (1) edge [loop above,looseness=3] node {0.6} (1)
        edge [bend right] node {0.4} (2)
    (2) edge node [below right]{1.0} (1)
    (3) edge [loop below] node {0.8} (3)
        edge node[above right] {0.1} (1)
        edge node[below] {0.1} (2);      
\end{tikzpicture}
\end{document}

enter image description here

To make the loops identical, use

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,calc,positioning}
\begin{document}       
\begin{tikzpicture}[->,>=Stealth,shorten >=1pt,auto,node distance=4cm,
    thick,main node/.style={circle,draw,font=\Large\bfseries,
    align=center,
    execute at begin node=\setlength{\baselineskip}{2em},
    },auto,]

  \path node[main node] (1) {1 \\ s}
   node[main node] (2) [below left=of 1] {2}
   node[main node] (3) [below right=of 1] {3};

  \path
    ([xshift=-1ex]1.north) edge [out=110,in=70,looseness=5] node {0.6}
    ([xshift=1ex]1.north)
    (1)   edge [bend right] node {0.4} (2)
    (2) edge node [below right]{1.0} (1)
    ([xshift=-1ex]3.south) edge [out=-110,in=-70,looseness=5] node[below] {0.8}
    ([xshift=1ex]3.south) (3)
        edge node[above right] {0.1} (1)
        edge node[below] {0.1} (2);      
\end{tikzpicture}
\end{document}

enter image description here

One can make this a style but I am running out of space and motivation here.

8
  • Thank you! But is there a way to keep them on the smaller side?
    – bvowe
    Mar 14, 2020 at 18:36
  • @bvowe Sure, increase the looseness, see the second part of the answer.
    – user194703
    Mar 14, 2020 at 18:41
  • So sorry--what I meant to say is for example in my example--is it possible to make the loop for (1 s) the same size as loop (3) ?
    – bvowe
    Mar 14, 2020 at 18:48
  • @bvowe You can decrease the looseness of the upper loop.
    – user194703
    Mar 14, 2020 at 18:51
  • Thank you! I could not find default loop values for example for angles and looseness--do you know them or where to source
    – bvowe
    Mar 14, 2020 at 18:54

You must log in to answer this question.

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