The answer referenced is https://tex.stackexchange.com/a/45735/180050 and is essential for this question.

In the given answer, it shows how you can easily make directed edges between specified nodes.

I was wondering how I could do the same but with undirected edges (lines with no arrows).


I appreciate the linked duplicate, and I used Jake's comment to the main post of adding [-] to edge for typical edges. However, this does not work for self-loops, and fixing that is not in the linked solution.

  • 4
    Remove -> and shorten>=1pt from the option list of the tikzpicture environment. For the loops you have to add every loop/.style={}.
    – esdd
    Commented Apr 24, 2019 at 6:27
  • @esdd I used Jake's comment to the main post here to solve the typical edge: tex.stackexchange.com/questions/52085/… Commented Apr 25, 2019 at 1:33
  • Is it possible to use something like edge[-] for a self-loop instead of changing the global settings? Like just remove the arrow from one loop with the default being to have the arrows? Commented Apr 25, 2019 at 1:34
  • I saw your post in the reopening queue and am wondering if you are simply looking for every loop/.append style={-} in the options of the tikzpicture. Notice that I did not (vote to) close your question, but I can see why people could want to close it. It would be much better if you added a simple example such that it is clear what you want (unless the above solved it already). Once this is done I will be happy to help you reopening the question.
    – user121799
    Commented Apr 25, 2019 at 2:14

1 Answer 1


The global switching off of arrows can be achieved as in esdd's comment or bay saying very loop/.append style={-}. Local switching off works essentially the same, I added a style no arrow for that.

\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,
                    thick,main node/.style={circle,draw,font=\sffamily\Large\bfseries},
                    no arrow/.style={-,every loop/.append style={-}}

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

  \path[every node/.style={font=\sffamily\small}]
    (1) edge node [left] {0.6} (4)
        edge [bend right] node[left] {0.3} (2)
        edge [no arrow,loop above] node {0.1} (1)
    (2) edge node [right] {0.4} (1)
        edge node {0.3} (4)
        edge [loop left] node {0.4} (2)
        edge [bend right] node[left] {0.1} (3)
    (3) edge node [right] {0.8} (2)
        edge [bend right] node[right] {0.2} (4)
    (4) edge node [left] {0.2} (3)
        edge [loop right] node {0.6} (4)
        edge [bend right] node[right] {0.2} (1);

enter image description here

  • Thanks for showing me how I can universally do it! Is there a way to have it such that the default adds an arrow and you can locally choose to make it not have an arrow? Commented Apr 25, 2019 at 20:41
  • Like how you can change edge node [left] {0.6} (4) to edge [-] node [left] {0.6} (4) to make a nonloop edge not have an arrow? Commented Apr 25, 2019 at 20:42
  • @GigiBayte2 Yes, it works the same way. I added a style no arrow that makes this more convenient. (One may argue that just adding -> is not such a great idea, but I take you want to keep this.)
    – user121799
    Commented Apr 25, 2019 at 20:49
  • Hi! Would it be possible to add an allowable style for each node similar to how you did the "no arrow" style to fill the node a certain color? Commented May 1, 2019 at 5:23
  • @GigiBayte2 \tikzset{every node/.append style={fill=blue}}?
    – user121799
    Commented May 1, 2019 at 5:25

You must log in to answer this question.

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