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 3017 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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
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 2997 times
Post Reply