1

I have a graph in TikZ. It can be planar, and I know what change I need to make to make it planar but I can't work out how to communicate this to TikZ.

I wish to force the NTN node to be to the left of the RvNN and/or RNN nodes. Which sounds fairly simple.

graph

MWE:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{graphs,graphdrawing}
\usegdlibrary{layered}

\begin{document}
\begin{tikzpicture}[
sibling sep=20mm,level sep=10mm, node distance=10mm
]
\graph[layered layout]{%
NN -> { NTN, RNN, AE };
RvNN -> { RvNTN,RvNTN, RAE};
RNN ->RvNN;
NTN-> RvNTN;
AE->RAE;

};

\end{tikzpicture}
\end{document}

It is fairly easy for me to look at many graphs and say what node order swaps need to be made so they can be drawn planar.

But a few related questions:

Have got me thinking maybe this is very hard.

I tried fiddling with edge weights and minimum layers, but got no where, and mostly made things worse.

1 Answers1

1

Moving NTN -> RvNTN up helps:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{graphs,graphdrawing}
\usegdlibrary{layered}

\begin{document}
\begin{tikzpicture}[
sibling sep=20mm,level sep=10mm, node distance=10mm
]
\graph[layered layout]{%
NN -> { NTN, RNN, AE };
NTN-> RvNTN;
RvNN -> { RvNTN,RvNTN, RAE};
RNN ->RvNN;
AE->RAE;

};

\end{tikzpicture}
\end{document}

Result

Heiko Oberdiek
  • 271,626
  • Why does it help? What is there a general rule? That works for the MWE, but how should I apply it in future? Should I just shuffle my node links til i get an order which works? – Frames Catherine White Sep 09 '15 at 12:19
  • @Oxinabox From the documentation, crossing minimization uses a heuristics, because the problem is NP hard. Heuristics means, that not all cases are caught at the optimum. That means, there are cases, where manual intervention can improve the outcome. – Heiko Oberdiek Sep 09 '15 at 13:00
  • I get that. But how can I use reordering the declaration in order to do manual intervention? It doesn't seem to be case of List the Left most Edges first? (or is it?) – Frames Catherine White Sep 09 '15 at 13:02
  • @Oxinabox The order of branch specifications matters, as can be seen in the answer. NN has three outgoing edges, the version in the question, first uses RNN, then NTN, the answer switches these and calls NTN->RvNTN before RNN->RvNN. Since the result is cross-free, the crossing minimization algorithm has nothing to improve and therefore no reason for reordering. – Heiko Oberdiek Sep 09 '15 at 13:08