4

I replicated the US Abilene topology in TikZ inspired by Botoeva's kb-exchange diagram. The following is the code for the example. I, however would like to present a 3-dimensional view of this topology on a plane, which is one of the reasons I turned to this forum for help. Additionally, I would also like to hear some suggestions on how to improve the picture even further, etc., I have to admit that I'm still a beginner when it comes to TikZ

\documentclass[tikz, border=5]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,shadows,calc}
\usepgflibrary{arrows}



% Snippets from www.texample.net/tikz/examples/kb-exchange
% Courtesy: Elena Botoeva

\tikzset{
  sshadow/.style={opacity=.25, shadow xshift=0.05, shadow yshift=0.06},
}

%------TBoxes
%------#1 height, #2 width, #3 anchor for the label
%------#4 name of the node, #5 coordinate, #6 label

\def\tboxr[#1,#2,#3,#4,#5]#6{%
  \node[draw, drop shadow={opacity=.35}, minimum height=#1, minimum width=#2, %
  inner color=brown!20, outer color=brown!45, color=brown!50!black] (#4) at #5 {}; %
  \node[anchor=#3, inner sep=2pt] at (#4.#3) {#6};
}


%------ABoxes
%------#1 height, #2 width, #3 aspect, #4 anchor, 
%------#5 name of the node, #6 coordinate, #7 label

\def\aboxl[#1,#2,#3,#4,#5,#6]#7{%
  \node[draw, cylinder, alias=cyl, shape border rotate=90, aspect=#3, %
  minimum height=#1, minimum width=#2, outer sep=-0.5\pgflinewidth, %
  color=orange!40!black, left color=orange!70, right color=orange!80, middle color=white] (#5) at #6 {}; %
  \node[anchor=#4, outer sep=-18pt] at (#5.#4) {#7}; %
  \fill [orange!30] let \p1 = ($(cyl.before top)!0.5!(cyl.after top)$), \p2 = 
  (cyl.top), \p3 = (cyl.before top), \n1={veclen(\x3-\x1,\y3-\y1)},
  \n2={veclen(\x2-\x1,\y2-\y1)} in (\p1) ellipse (\n1 and \n2); }

\begin{document}
\begin{tikzpicture}

\small

% Layout for the topology
\tboxr[600,1500,north east,t1,(-98,39)]{$\texttt{www.sndlib.zib.de}$};


% Nodes of the network
\aboxl[30,40,1.6,south,n1,(-82.38,32.45)] {$\textit{ATLAM5}$}
\aboxl[30,40,1.6,south,n2,(-84.38,33.75)] {$\textit{ATLAng}$}
\aboxl[30,40,1.6,south,n3,(-87.62,41.83)] {$\textit{CHINng}$}
\aboxl[30,40,1.6,south,n4,(-105.0,40.75)] {$\textit{DNVRng}$}
\aboxl[30,40,1.6,south,n5,(-95.52,29.77)] {$\textit{HSTNng}$}
\aboxl[30,40,1.6,south,n6,(-86.16,39.78)] {$\textit{IPLSng}$}
\aboxl[30,40,1.6,south,n7,(-96.60,38.96)] {$\textit{KSCYng}$}
\aboxl[30,40,1.6,south,n8,(-118.3,34.05)] {$\textit{LOSAng}$}
\aboxl[30,40,1.6,south,n9,(-73.97,40.78)] {$\textit{NYCMng}$}
\aboxl[30,40,1.6,south,n10,(-122.0,37.39)] {$\textit{SNVAng}$}
\aboxl[30,40,1.6,south,n11,(-122.3,47.60)] {$\textit{STTLng}$}
\aboxl[30,40,1.6,south,n12,(-77.03,38.90)] {$\textit{WASHng}$}


% Edges of the network
\draw[-latex] (n1) to [bend right=3] (n2);
\draw[-latex] (n2) to [bend right=3] (n1);

\draw[-latex] (n2) to [bend right=3] (n5);
\draw[-latex] (n5) to [bend right=3] (n2);

\draw[-latex] (n2) to [bend right=3] (n6);
\draw[-latex] (n6) to [bend right=3] (n2);

\draw[-latex] (n2) to [bend right=3] (n12);
\draw[-latex] (n12) to [bend right=3] (n2);

\draw[-latex] (n3) to [bend right=3] (n6);
\draw[-latex] (n6) to [bend right=3] (n3);

\draw[-latex] (n3) to [bend right=3] (n9);
\draw[-latex] (n9) to [bend right=3] (n3);

\draw[-latex] (n4) to [bend right=3] (n7);
\draw[-latex] (n7) to [bend right=3] (n4);

\draw[-latex] (n4) to [bend right=3] (n10);
\draw[-latex] (n10) to [bend right=3] (n4);

\draw[-latex] (n4) to [bend right=3] (n11);
\draw[-latex] (n11) to [bend right=3] (n4);

\draw[-latex] (n5) to [bend right=3] (n7);
\draw[-latex] (n7) to [bend right=3] (n5);

\draw[-latex] (n5) to [bend right=3] (n8);
\draw[-latex] (n8) to [bend right=3] (n5);

\draw[-latex] (n6) to [bend right=3] (n7);
\draw[-latex] (n7) to [bend right=3] (n6);

\draw[-latex] (n8) to [bend right=3] (n10);
\draw[-latex] (n10) to [bend right=3] (n8);

\draw[-latex] (n9) to [bend right=3] (n12);
\draw[-latex] (n12) to [bend right=3] (n9);

\draw[-latex] (n10) to [bend right=3] (n11);
\draw[-latex] (n11) to [bend right=3] (n10);

\end{tikzpicture}
\end{document}

enter image description here

Here is the second segment which I intend to use for my explanation along with the above topology example

\documentclass[tikz, border=5]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,shadows,calc}

\usetikzlibrary{arrows, automata}




% Snippets from www.texample.net/tikz/examples/kb-exchange
% Courtesy: Elena Botoeva

\tikzset{
  sshadow/.style={opacity=.25, shadow xshift=0.05, shadow yshift=0.06},
}


%-----Layout
%-----#1 height, #2 width, #3 xslant, #4 yslant
%-----#5 anchor for the label, #6 name of the node
%-----#7 coordinate. #8 label

\def\layr[#1,#2,#3,#4,#5,#6,#7]#8{%
  \node[draw,drop shadow={opacity=.35},minimum height=#1,minimum width=#2, %
  xslant=#3,yslant=#4,inner color=white!40, outer color=gray!30, color=gray!50!black] (#6) at #7 {}; %
  \node[anchor=#5, inner sep=2pt] at(#6.#5) {#8};
}



%-----EndNodes
%-----#1 height, #2 width, #3 xslant, #4 yslant
%-----#5 anchor for the label, #6 name of the node
%-----#7 coordinate, #8 label

\def\endr[#1,#2,#3,#4,#5,#6,#7]#8{%
  \node[draw,drop shadow={opacity=.15},minimum height=#1,minimum width=#2, %
  xslant=#3,yslant=#4,inner color=red!20, outer color=red!45, color=red!50!black] (#6) at #7 {}; %
  \node[anchor=#5, inner sep=2pt] at(#6.#5) {#8};
}


%-----VNFNodes
%-----#1 height, #2 width, #3 xslant, #4 yslant
%-----#5 anchor for the label, #6 name of the node
%-----#7 coordinate, #8 label
\def\vnfr[#1,#2,#3,#4,#5,#6,#7]#8{%
  \node[draw,drop shadow={opacity=.15},minimum height=#1,minimum width=#2, %
  xslant=#3,yslant=#4,inner color=blue!20, outer color=blue!45, color=blue!50!black] (#6) at #7 {}; %
  \node[anchor=#5, inner sep=2pt] at(#6.#5) {#8};
}


\begin{document}
\begin{tikzpicture}[auto, outer sep=3pt, node distance=2cm, >=latex']

% Layout for the topology
\layr[100,450,-2,0,center,t,(0,0)]{};


\begin{scope}[xshift=0.4cm, yshift=0cm]
\endr[10,20,-2,0,center,lA,(-9.7,1.20)]{\tiny $e_1$};

\vnfr[7,30,-2,0,center,vlA,(-7.2,1.20)]{\tiny $\textit{vnf}_1$};
\vnfr[7,30,-2,0,center,vlB,(-2.7,1.50)]{\tiny $\textit{vnf}_2$};
\vnfr[7,30,-2,0,center,vlC,(-4.2,0.90)]{\tiny $\textit{vnf}_3$};
\vnfr[7,30,-2,0,center,vlD,(-0.2,0.90)]{\tiny $\textit{vnf}_4$};
\vnfr[7,30,-2,0,center,vlE,(2.00,1.20)]{\tiny $\textit{vnf}_5$};

\endr[10,20,-2,0,center,rA,(4.2,1.20)]{\tiny $e_2$};

\draw [<->, thick, dashed] (lA) -- node {} (vlA);
\draw [<->, thick, dashed] (vlA) -- node {} (vlB);
\draw [<->, thick, dashed] (vlA) -- node {} (vlC);
\draw [<->, thick, dashed] (vlC) -- node {} (vlD);
\draw [<->, thick, dashed] (vlB) -- node {} (vlE);
\draw [<->, thick, dashed] (vlD) -- node {} (vlE);
\draw [<->, thick, dashed] (vlE) -- node {} (rA);
\end{scope}



\begin{scope}[xshift=2.8cm, yshift=-1.2cm]
\endr[10,20,-2,0,center,lA,(-9.7,1.20)]{\tiny $e_1$};

\vnfr[7,30,-2,0,center,vlA,(-7.2,1.20)]{\tiny $\textit{vnf}_1$};
\vnfr[7,30,-2,0,center,vlB,(-2.7,1.50)]{\tiny $\textit{vnf}_2$};
\vnfr[7,30,-2,0,center,vlC,(-4.2,0.90)]{\tiny $\textit{vnf}_3$};
\vnfr[7,30,-2,0,center,vlD,(-0.2,0.90)]{\tiny $\textit{vnf}_4$};
\vnfr[7,30,-2,0,center,vlE,(2.00,1.20)]{\tiny $\textit{vnf}_5$};

\endr[10,20,-2,0,center,rA,(4.2,1.20)]{\tiny $e_2$};

\draw [<->, thick] (lA) -- node {} (vlA);
\draw [<->, thick] (vlA) -- node {} (vlB);
\draw [<->, thick] (vlA) -- node {} (vlC);
\draw [<->, thick] (vlC) -- node {} (vlD);
\draw [<->, thick] (vlB) -- node {} (vlE);
\draw [<->, thick] (vlD) -- node {} (vlE);
\draw [<->, thick] (vlE) -- node {} (rA);
\end{scope}



\begin{scope}[xshift=5.2cm, yshift=-2.4cm]
\endr[10,20,-2,0,center,lA,(-9.7,1.20)]{\tiny $e_1$};

\vnfr[7,30,-2,0,center,vlA,(-7.2,1.20)]{\tiny $\textit{vnf}_1$};
\vnfr[7,30,-2,0,center,vlB,(-2.7,1.50)]{\tiny $\textit{vnf}_2$};
\vnfr[7,30,-2,0,center,vlC,(-4.2,0.90)]{\tiny $\textit{vnf}_3$};
\vnfr[7,30,-2,0,center,vlD,(-0.2,0.90)]{\tiny $\textit{vnf}_4$};
\vnfr[7,30,-2,0,center,vlE,(2.00,1.20)]{\tiny $\textit{vnf}_5$};

\endr[10,20,-2,0,center,rA,(4.2,1.20)]{\tiny $e_2$};

\draw [<->, thick, dotted] (lA) -- node {} (vlA);
\draw [<->, thick, dotted] (vlA) -- node {} (vlB);
\draw [<->, thick, dotted] (vlA) -- node {} (vlC);
\draw [<->, thick, dotted] (vlC) -- node {} (vlD);
\draw [<->, thick, dotted] (vlB) -- node {} (vlE);
\draw [<->, thick, dotted] (vlD) -- node {} (vlE);
\draw [<->, thick, dotted] (vlE) -- node {} (rA);
\end{scope}

\end{tikzpicture}

\end{document}

enter image description here

  • You could superimpose the actual map following tex.stackexchange.com/a/183138/36686 – Bordaigorl Oct 18 '16 at 10:04
  • Also, I find a (thick) single link with arrow heads on both sides (<->) would be better looking and more readable than drawing two arcs one for each direction – Bordaigorl Oct 18 '16 at 10:05
  • Finally, I would advise you to reconsider the 3D view. What is the purpose of the figure? A 3D view may distort the perception of distances for example. Is that important? Or you are just looking for some theatrical for aesthetic reasons? – Bordaigorl Oct 18 '16 at 10:08
  • I want to project the topology on a plane. Such a modification would give the topology an appearance of a layer/slice. But I some help. Ok, as an answer to your comment, I want to be able to show something like this tex.stackexchange.com/questions/325079/…. Moreover, the distance metrics aren't important here. I intend to show a mapping of one virtual slice on the underlying topology which is why I desire a 3D view – crypto Oct 18 '16 at 10:10
  • I see. Well in that case you do not need a full 3D view but could replicate the effect by applying a slant transformation and some scaling. See the xslant option in the manual – Bordaigorl Oct 18 '16 at 10:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.