In my job I often draw network diagrams. Connections are usually doubled for safe redundant operation. Also, connections can be bundled for performance reasons, so there may be four connections between two devices.
I need to indicate that two edges belong to the same bundle. We say port channel or Ethernet channel for such aggregated connections between switches. Usually, they are indicated by a summarising ellipse in the middle of parallel lines.
It would be very helpful for network engineers who use TikZ instead of MS Visio to have an edge style for channels.
I started to create one:
- parallel edges, 2 or 4 (other numbers rarely occur)
- ellipse split into two arcs
- either drawn as
preactionandpostaction - or on background and foreground layer
- a border around lines is good for indicating a crossing (we could use a
doublestyle for line and arc)
- either drawn as
Here is my code for a start:
\documentclass[tikz, border=2pt]{standalone}
\usetikzlibrary{arrows.meta,decorations.markings}
\def\bundlesep{2pt}% distance between parallel edges
\def\bundleX{0.8*\bundlesep}
\def\bundleY{1.8*\bundlesep}% x and y radius of ellipse
\tikzset{
arc/.style = { x radius = \bundleX, y radius = \bundleY,
start angle = 90, delta angle = 180},
arrow/.style = {{Bar[white, width = \bundlesep,length=0pt]}-{Bar[white,
width = \bundlesep, length = 0pt]}},% just a workaround fixing `double` bug
decomark/.style = {black, thick, yshift = \bundleY, -, shorten <=-0.1pt},% arc style
ellipse/.style = {
preaction = {decorate, decoration = {markings,
mark = at position 0.5 with {\draw[decomark, shorten >=-0.1pt] (0,0)
arc [arc, delta angle = -180];}}},
postaction = {decorate, decoration = {markings,
mark=at position 0.5 with {\draw[decomark] (0,0)
arc [arc];}}}},% consisting of 2 arcs
bundle/.style = {double, line width = 0.5pt, double distance = \bundlesep,
arrow, ellipse},
single/.style = {white, double = black, line width = 0.4pt,
double distance = 0.8pt, arrow, ellipse}
}
\begin{document}
\begin{tikzpicture}
\draw [bundle] (0,0) -- (3,0);
\draw [single] (0,-0.5) -- (3,-0.5);
\end{tikzpicture}
\end{document}
These are two examples:
I used a
doublepath for two parallel edges. I wish there was aquadpath! How can I have 4 lines?This shows how the bundling circle, drawn as ellipse, has a foreground part and a background part behind the line, gaps help to see the crossing. Also the arc should have some white space around for the other crossing.
Throwing this together and improving it to have an easy to use edge style, what would be the best way to draw a bundle of edges with a "3D" circle, that is, an ellipse around the 2 or 4 edges bundle?






calcsyntax. Please let me know if you would like to see an example. I chose decorations since this may be easier to customize if you ever decide to also draw bent paths. – Oct 20 '18 at 20:14edge bundlewhich gets fed with the specifics forsingle,bundleandquad. Please have a look and tell me whether those go in the right direction. – Oct 21 '18 at 15:24