14

I came across this graph in the question Drawing graphs in LaTeX:

enter image description herewithout arrows?

Is it possible to draw graphs like this one in LaTeX but without the arrows?

edit: I found this piece below, but I do not know how to replace the arrows with simple edges.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,
                    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=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 [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);
\end{tikzpicture}
\end{document}
2
  • It is fairly easy to draw graphslike using in latex. My preferred tool is tikz. If you look at the answers to the question where you found this picture you shouldn't much difficulty in getting rid of the arrows (just remove the ->). Please have a look at the TeX.SX guidelines on how to write a minimal working example.
    – user30471
    Commented May 7, 2015 at 6:14
  • Oh thank you Andrew. I did not realize that such a task was so simple.
    – Flair
    Commented May 7, 2015 at 6:26

3 Answers 3

12

You just need to take out the arrow commands -> and set the loop style to empty:

enter image description here

All of the credit is due to @Stefan Kottwitz for creating the original picture.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[auto, node distance=3cm, every loop/.style={},
                    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=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 [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);
\end{tikzpicture}
\end{document}
3
  • I'd change the edge node {0.3} (4) to non overlap the text. Or maybe fill its background with white colour.
    – Sigur
    Commented May 7, 2015 at 6:40
  • 1
    Yes, @Sigur and @Flair edge node[below] {0.3} (4) is better.
    – corporal
    Commented May 7, 2015 at 6:54
  • @Sigur @Flair I think it's cleaner to put auto back into the tikzpicture options...unless you really want the label below the edge. I have edited the answer to do this.
    – user30471
    Commented May 7, 2015 at 8:23
3

Maybe you are more confortable with tikz-cd which uses a quite easy syntax for such things. The line every arrow/.append style={dash} sets every arrow to just a line without arrow heads.

% arara: pdflatex

\documentclass{article}
\usepackage{tikz-cd}

\begin{document}
\begin{tikzcd}[%
    ,cells={nodes={circle,draw,font=\sffamily\Large\bfseries}}
    ,every arrow/.append style={dash,thick}
    ]
& 
1\arrow{dl}{0.2}\arrow[bend left]{dr}{0.2}\arrow[loop above, near end, "0.1"] 
& \\
%%%%%%%%%%%
2\arrow[loop left, near end, "0.4"]\arrow[bend left]{ur}{0.3}\arrow{dr}{0.8}
& & 
4\arrow[loop right, near start, "0.6"]\arrow{ul}{0.6}\arrow[bend left]{dl}{0.2}\arrow{ll}{0.3} \\
%%%%%%%%%%%
& 
3\arrow{ur}{0.2}\arrow[bend left]{ul}{0.1} 
& 
\end{tikzcd}
\end{document}

enter image description here

0
2

Here is one done wither pstricks. The loops are parts of strophoids, as it was the closest curve to the original figure I know.

\documentclass[pdf, svgnames, x11names]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{pst-node, pst-plot, pst-poly}
\usepackage{rotating}
\newcommand\myloop{\psplot[yunit = 1.6, plotpoints=200,plotstyle=curve, polarplot, algebraic, arrows = c-c]{-0.785}{0.785}{cos(2*x)/cos(x)}}

\begin{document}

\psset{unit=3cm, linecolor=LightSteelBlue}
\degrees
\begin{pspicture}%
    \sffamily\large
    \pnode(0,0){O}
    \pscircle(O){1}
    \multido{\I=90+90,\i=1 + 1}{4}{%
        \pnode(1.15; \I){L\i}{\psset{origin=L\i, unit = 0.4}\rotatebox{\numexpr\I}{\myloop}}
        \cnodeput[framesep=0.15, fillstyle=solid, fillcolor=white,linecolor=IndianRed!60!, linewidth=1pt](1;\I){A\i}{\bfseries\i}
    }
    \psset{labelsep=1.05}
    \nput{45}{O}{0.2}\nput{135}{O}{0.4}
    \nput{-45}{O}{0.2}\nput{-135}{O}{0.1}
    \nput[labelsep=2.7em]{50}{L1}{0.1}
    \nput[labelsep=2.4em]{135}{L2}{0.4}
    \nput[labelsep=2.4em]{45}{L4}{0.6}
    \ncline{A1}{A2}\naput{0.2}
    \ncline{A2}{A3}\naput{0.8}
    \ncline{A3}{A4}\naput{0.2}
    \ncline{A4}{A1}\naput{0.6}
\end{pspicture}

\end{document}

enter image description here

You must log in to answer this question.

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