7

The MWE below produces a simple graph. When I add the two upper nodes A1 and B1 to a subgraph the horizontal alignment is lost which is understandable, since the nodes in the subgraph are positioned independent of the others. What I don't understand is that the connection from B1 to B3 is not straight anymore. How can I fix this while keeping the subgraph?

Note: I need to use subgraphs in a much more complex example where I get the same Problem.

\documentclass[border=0.125cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{graphs,quotes} 
\usegdlibrary{trees,layered,force}
\begin{document} 
\tikz \graph[layered layout] { 
    "A1";
    "B1";    
    "B3";
    "A2";
    "A3";
    "C";  
    "A2" -- "A3";
    "A3" -- "C";
    "B1" --[minimum layers=2] "B3";
    "A1" -- "A2";
    "B3" -- "C";
};
\tikz \graph[layered layout] { 
//[layered layout]{
    "A1";
    "B1";
    };
    "B3";
    "A2";
    "A3";
    "C";     
    "A2" -- "A3";
    "A3" -- "C";
    "B1" --[minimum layers=2] "B3";
    "A1" -- "A2";
    "B3" -- "C";
};
\end{document}

enter image description here

  • Though the question is not new I'm still hoping for some help. The problem is simple enough that other users might run into it. The graphdrawing library is a great alternative to graphviz but this bug makes it unusable for me. – dukeeloo Feb 14 '16 at 15:14
1

A late workaround: set bend left=0 for this edge or all edges:

%! TEX program = lualatex
\RequirePackage{luatex85}
\documentclass[border=0.125cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{graphs,quotes} 
\usegdlibrary{trees,layered,force}
\begin{document} 
\tikz \graph[layered layout] { 
    "A1";
    "B1";    
    "B3";
    "A2";
    "A3";
    "C";  
    "A2" -- "A3";
    "A3" -- "C";
    "B1" --[minimum layers=2] "B3";
    "A1" -- "A2";
    "B3" -- "C";
};
\tikz \graph[layered layout,edges={bend left=0}] { 
//[layered layout]{
    "A1";
    "B1";
    };
    "B3";
    "A2";
    "A3";
    "C";     
    "A2" -- "A3";
    "A3" -- "C";
    "B1" --[minimum layers=2, bend left=0] "B3";
    "A1" -- "A2";
    "B3" -- "C";
};
\end{document}

enter image description here

  • Late but still relevant to me:) I accepted this answer since it solves the problem in the MWE. When I try it on my bigger graph it produces the error: "Dimension too large. <recently read> \pgf@xa". When I simplify the graph the error goes away at some point but I dont know how to isolate the probelem. – dukeeloo May 17 '18 at 16:46

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.