I usually need to draw graphs with multiple edges. I would really appreciate if someone can tell me how to write a multiple edge command which will allow me to write one line instead of repeatedly many. Say the name of my edge command is \myedge[m]
meaning that I will draw m edges between two nodes.
I want to use something like the following whenever I need to draw a multiple edge (multiplicity is 5 in the following)
\draw (a) \myedge[5] (b);
Here is my actual code example... It is troublesome to keep using it in graphs where I have to keep drawing edges.
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}
\node[circle,fill=black,inner sep=1.5pt,draw] (a) at (180:1cm) {};
\node[circle,fill=black,inner sep=1.5pt,draw] (b) at (0:1cm) {};
\draw[thick] (a) -- (b);
\end{tikzpicture}
\begin{tikzpicture}
\node[circle,fill=black,inner sep=1.5pt,draw] (a) at (180:1cm) {};
\node[circle,fill=black,inner sep=1.5pt,draw] (b) at (0:1cm) {};
\draw[thick] (a) edge[bend left=5] (b);
\draw[thick] (a) edge[bend right=5] (b);
\end{tikzpicture}
\begin{tikzpicture}
\node[circle,fill=black,inner sep=1.5pt,draw] (a) at (180:1cm) {};
\node[circle,fill=black,inner sep=1.5pt,draw] (b) at (0:1cm) {};
\draw[thick] (a) edge[bend left] (b);
\draw[thick] (a) edge (b);
\draw[thick] (a) edge[bend right] (b);
\end{tikzpicture}
\begin{tikzpicture}
\node[circle,fill=black,inner sep=1.5pt,draw] (a) at (180:1cm) {};
\node[circle,fill=black,inner sep=1.5pt,draw] (b) at (0:1cm) {};
\draw[thick] (a) edge[bend left=15] (b);
\draw[thick] (a) edge[bend left=5] (b);
\draw[thick] (a) edge[bend right=5] (b);
\draw[thick] (a) edge[bend right=15] (b);
\end{tikzpicture}
\begin{tikzpicture}
\node[circle,fill=black,inner sep=1.5pt,draw] (a) at (180:1cm) {};
\node[circle,fill=black,inner sep=1.5pt,draw] (b) at (0:1cm) {};
\draw[thick] (a) edge[bend left=16] (b);
\draw[thick] (a) edge[bend left=8] (b);
\draw[thick] (a) edge[bend right=8] (b);
\draw[thick] (a) edge[bend right=16] (b);
\draw[thick] (a) -- (b);
\end{tikzpicture}
\end{center}
\end{document}
Output:
SITUATION: Here is what exactly I want to do in this new definition: Say, I would like to bend perpendicular to the line connecting two nodes (u)
and (v)
with coordinates (a,b)
and (c,d)
. This gives me the chance to use ((c-a)*0.2*\i,(d-b)*0.2*\i)
instead of $(0,0.2*\i)$
and it is most general. However, I can see that the bigger trouble here is that in defining edge[me=<number>]
you actually do not account the ends of the edge. Can we do that?
This would certainly prevent the curly edges when edges are not on a horizontal line (it is worst when they are vertical actually). On the other hand, depending on how big is r=\sqrt{(c-a)^2+(d-b)^2}
is, we might need to replace 0.2
with a much smaller/larger number. Maybe it is a good idea even to replace 0.2
with \frac{0.2}{r}
.
!
at the start of the line where the image is included - someone can put that back in afterwards. I also cleaned up your code a little.