Graphics, Figures & TablestikZ | Parallel Edges between Nodes

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
kirpich
Posts: 2
Joined: Wed Nov 28, 2012 8:43 am

tikZ | Parallel Edges between Nodes

Post by kirpich »

I'm looking for a simple way to draw the following picture using tikZ. Namely, I would like to only specify the coordinates of the cities and then to connect them by edges using a \foreach loop. This would be easy if there were no directed edges at this picture.
Attachments
tikZ-parallel-edges.png
tikZ-parallel-edges.png (33.09 KiB) Viewed 2973 times
Last edited by localghost on Wed Nov 28, 2012 10:58 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

tikZ | Parallel Edges between Nodes

Post by Stefan Kottwitz »

Hi kirpich,

welcome to the board!

Actually every connection consists of three edges of the same type, so drawing edge, arrow to the left and to the right in one step of the \foreach loop could be a possibility.

A different approach would be making three \foreach loops, one for the connecting edge, one for the arrows in one direction, with the label on it, and one for the other direction.

Perhaps show, what you already got, if just the edges remain to be a problem.

Stefan
LaTeX.org admin
kirpich
Posts: 2
Joined: Wed Nov 28, 2012 8:43 am

tikZ | Parallel Edges between Nodes

Post by kirpich »

Hi Stefan,

Well, this is what I currently have:

Code: Select all

  \begin{scope}
  \foreach \x/\y/\name/\label/\where in {1.2/1.4/a/{El Paso}/below, 1/3.2/b/Albuquerque
/above, 2.5/3/c/Amarillo/below, 3.8/4/d/Wichita/above, 4.3/3.3/e/Tulsa/45, 5.2/2.8/f/{Little Rock}/right, 4.2/2/g/Dallas/left, 4.8/1/h/Houston/right, 3.6/0.6/i/{San Antonio}/below} {
    \draw (\x,\y) circle (.4mm);
    \node[draw,circle,minimum size=2mm,inner sep=0mm,label=\where:{\footnotesize \label}] (\name) at (\x,\y) {};
  }
  
  \foreach \s/\t in {a/b, b/c, c/e, e/d, e/f, f/g, h/g, h/i}
    \path[draw] (\s) edge (\t);
  \end{scope}
Attachments
tikz.png
tikz.png (18.93 KiB) Viewed 2953 times
Post Reply