How to implement Grandchild (Enkel1) into Family-Tree with graphviz?

后端 未结 1 422
一个人的身影
一个人的身影 2021-01-27 09:09

I´m building a Family tree with Grandparents, Parents, Children and Grandchildren (Children with Ex-Partners are possible too). Its working perfect, but there is a Problem with

相关标签:
1条回答
  • 2021-01-27 09:30

    You need to force the order of the last (Bart) row with invisible edges; I have added

    { rank = same; Schwiegertochter -> Lisa -> Maggie[ style = invis ] }
    

    at the bottom; I also have (more for my own pleasure than for real need) cleaned up the code, coming up with

    digraph G 
    { 
        graph[ splines=ortho, pad="0.4", nodesep="0.2", ranksep="0.2" ];
        mindist=1
    
        node[ shape=box, regular=0,color="black", style="filled" fillcolor="grey", width=1.5, height = 0.5, fontsize=10 ]; 
        "Max\nMustermann", "Maxi\nTestermann", "Moritz\nMustermann", "Nina\nMustermann"; 
        "Volker\nVersuch", "Veronika\nVersuch", "Maximilian\nMustermann", "Maxima\nMustermann"; 
        "Bart", "Lisa", "Maggie", "Ex\nPartner", "Schwiegertochter", "Enkel1", "Ex-Kind";
    
        node[ shape=circle,label="",height=0.01,width=0.01 ];
        a1, b1, b2, b3, c1, x1, p1, p2, p3, q1, q2, q3, v1;
    
        edge[ dir=none ];
    
        { rank=same; "Maximilian\nMustermann" -> a1 -> "Maxima\nMustermann" }
        { rank=same; b1 -> b2 -> b3 }
        a1 -> b2; 
        b1 -> "Max\nMustermann"; 
        b2 -> "Maxi\nTestermann";
        b3 -> "Moritz\nMustermann";
    
        { rank=same; "Ex\nPartner" -> c1 -> "Moritz\nMustermann" }
    
        c1->"Ex-Kind";
    
    
        { rank=same; "Volker\nVersuch" -> x1 -> "Veronika\nVersuch" }
        { rank=same"Maxima\nMustermann"; "Volker\nVersuch" }
        x1 ->  "Nina\nMustermann"; 
    
        { rank=same; "Moritz\nMustermann" -> p1 -> "Nina\nMustermann"}
        { rank=same;q1 -> q2 -> q3}
        { rank=same;"Bart";"Lisa";"Maggie" }
    
        p1 -> p2 -> p3 ->q2; 
        q1 -> Bart; 
        q2 -> Lisa;
        q3 -> Maggie;
    
        { rank=same; "Bart" -> v1 -> "Schwiegertochter" }
        { rank = same; Schwiegertochter -> Lisa -> Maggie[ style = invis ] }
        v1 -> Enkel1;
    }
    

    which gives you

    0 讨论(0)
提交回复
热议问题