3

my code produces the following graph:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{dot2texi}
\begin{document}    
\begin{tikzpicture}[auto]
\tikzstyle{n} = [draw,shape=rectangle,minimum size=2em,inner sep=2pt,align=center, font=\sffamily]
    \begin{dot2tex}[dot,tikz,codeonly,styleonly, options= -s ]
        digraph G  {

        overlap = false;
        node [style="n"];
        root
        top1
        top2
        subgraph cluster_top3 {
            top3 ;  
            color=invis;

            top3 -> {311 312} -> 32 -> {331 332 333} -> 34 -> 35 -> 36;
        }
        subgraph cluster_top4 {
            color=invis;
            top4 -> 41 -> {421 422} -> 43 -> 44 -> 45;              
        }
        root -> {top1 top2 top3 top4};
        }   
    \end{dot2tex}
\end{tikzpicture}
\end{document}

enter image description here

Is there a way to produce symmetric subgraphs without fiddling with invisible nodes/edges? I want the triangles 311 -- top3 -- 312 and 421 -- 41 -- 422 to have a square angle.

1

After digging in the pgf manual I came up with this solution. The levels of the sub trees are miss aligned though.

\RequirePackage{luatex85}
\documentclass\[tikz,12pt,border=0pt\]{standalone}
\usepackage{tikz}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{graphs}
\usegdlibrary{trees}
\usegdlibrary{layered}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}\[>=stealth, -, line width=2pt, every node/.style={circle,  font=\Large, draw=black, minimum size=1.45cm,  fill=white, anchor=center, align=center, line width=2pt}\]
\graph \[tree layout, level distance=2cm, sibling distance=2cm, components go up center aligned=true\]
    {
        "top" -- {1, 2, 3, 4};
        // \[layered layout,  level distance=2cm, sibling distance=2cm\]{{311, 312} -- 32 -- {331, 332, 333} -- 34};
        3 -- {311, 312};

        // \[layered layout,  level distance=2cm, sibling distance=2cm\] {41 -- {421, 422} -- 43;};
        4 -- 41;
    };
\end{tikzpicture}
\end{document}

enter image description here

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.