0

I am having issues on keeping Marge near Homer and Herb near Lucia to avoid this above-line (check the image). Basicly i need to keep married couples together and push aside brothers to fix the lines from mixing. Here is my source code:

digraph G {
  edge [dir=none];
  node [shape=box];
  graph [splines=ortho];

  "Abraham"   [shape=box, regular=0, color="blue", style="filled" fillcolor="lightblue"] ;
  "Mona"      [shape=box, regular=0, color="red", style="filled" fillcolor="pink"] ;
  a1 [shape=diamond,label="",height=0.25,width=0.25];
  {rank=same; Abraham -> a1 -> Mona};
  "Herb"      [shape=box, regular=0, color="blue", style="filled" fillcolor="lightblue"] ;
  "Lucia"     [shape=box, regular=0, color="red", style="filled"fontcolor="", fillcolor="pink"] ;
  "Homer"     [shape=box, regular=0, color="blue",fontcolor="blue", style="bold, filled" fillcolor="lightblue"] ;
  "Marge"     [shape=box, regular=0, color="red", style="bold,filled"fontcolor="red", fillcolor="pink"] ;
  p2 [shape=diamond,label="",style="",height=0.25,width=0.25];
  {rank=same; Herb -> p2 -> Lucia };
  {rank=same; Herb; Homer}
  b1 [shape=circle,label="",height=0.01,width=0.01];
  b2 [shape=circle,label="",height=0.01,width=0.01];
  b3 [shape=circle,label="",height=0.01,width=0.01];
{rank=same; b1 -> b2 -> b3};
  a1 -> b2;
  b1 -> Herb;
  b3 -> Homer;
  "Gendry"      [shape=box, regular=0, color="blue", style="filled" fillcolor="lightblue"] ;
  Herb -> Gendry;
  p2 -> c2;
  c1 -> Bob;
  c3-> John;
  {rank=same;  c1 -> c2 -> c3}
   c1 [shape=circle,label="",height=0.01,width=0.01];
  "Bob"      [shape=box, regular=0, color="blue", style="filled" fillcolor="lightblue"] ;
  c2 [shape=circle,label="",height=0.01,width=0.01];
  "John"      [shape=box, regular=0, color="blue", style="filled" fillcolor="lightblue"] ;
  c3 [shape=circle,label="",height=0.01,width=0.01];
   
  p1 [shape=diamond,label="",style="bold",height=0.25,width=0.25];
  {rank=same; Homer -> p1 -> Marge};
  {rank=same; Bob; John; Gendry}
}

family-tree-image

  • Hello! I'm afraid your question is difficult to answer as is so in order to get more (useful) answers, I suggest a few changes. The title of the question is not actually related to your problem (your problem has to do with lay-out and is not specific to family trees). Also, "dot" is a language that many people are not going to be aware about so please make sure it's clear you are asking a question about a language called "dot". Finally, your example is fairly complex. Is there any way you can simplify to make it easier to understand? – Paul Dec 02 '20 at 17:01
  • Thanks alot for your suggestions. I tried following some of them but the example is complex because if I remove some of the content the alignment is kind of correct. To start noticing issues there must be 3 generations. – Neofytos Konstantinidis Dec 02 '20 at 20:01

1 Answers1

0

What you want should be straight-forward using dot, but as you found, it is impressively difficult. Two techniques that should get you there are adding weight attributes to edges to keep nodes close to each other and/or using clusters to explicitly group the couples close. Using clusters does keep the couples together, but it resulted in ugly edges. Adding weights helped to get the invisible nodes placed "correctly" and resulted in nicer-looking edges.

digraph G {
  edge [dir=none];
  node [shape=box];
  graph [splines=ortho];

  subgraph cluster1{
      peripheries=0
  "Abraham"   [shape=box, regular=0, color="blue", style="filled" fillcolor="lightblue"] ;
  "Mona"      [shape=box, regular=0, color="red", style="filled" fillcolor="pink"] ;
  a1 [shape=diamond,label="",height=0.25,width=0.25];
  {rank=same; Abraham -> a1 -> Mona};
  }

  subgraph cluster3{
  peripheries=0
  "Homer"     [shape=box, regular=0, color="blue",fontcolor="blue", style="bold, filled" fillcolor="lightblue"] ;
  "Marge"     [shape=box, regular=0, color="red", style="bold,filled"fontcolor="red", fillcolor="pink"] ;
  {rank=same; Homer -> p1 -> Marge};
  p1 [shape=diamond,label="",style="bold",height=0.25,width=0.25];
  }
  subgraph cluster2{
      peripheries=0
  "Herb"      [shape=box, regular=0, color="blue", style="filled" fillcolor="lightblue"] ;
  "Lucia"     [shape=box, regular=0, color="red", style="filled"fontcolor="", fillcolor="pink"] ;
  {rank=same; Herb -> p2 -> Lucia };
  p2 [shape=diamond,label="",style="",height=0.25,width=0.25];
  }

  b1 [shape=point style=invis width=0 label=""]  //,height=0.01,width=0.01];
  b2 [shape=point style=invis width=0 label=""]  //,height=0.01,width=0.01];
  b3 [shape=point style=invis width=0 label=""]  //,height=0.01,width=0.01];
  {rank=same; weight=0   b1 -> b2 -> b3};
  {
  a1 -> b2;
  b1 -> Herb  [weight=9]
  b3 -> Homer [weight=9]
  }

  "Gendry"      [shape=box, regular=0, color="blue", style="filled" fillcolor="lightblue"] ;

  {rank=same; weight=0  c1 -> c2 -> c3}
   c1 [shape=circle,label="",height=0.01,width=0.01];
  "Bob"      [shape=box, regular=0, color="blue", style="filled" fillcolor="lightblue"] ;
  c2 [shape=circle,label="",height=0.01,width=0.01];
  "John"      [shape=box, regular=0, color="blue", style="filled" fillcolor="lightblue"] ;
  c3 [shape=circle,label="",height=0.01,width=0.01];
   
  Herb -> Gendry;
  p2 -> c2 weight=99;
  c1 -> Bob weight=99;
  c3-> John weight=99;
  {rank=same; Bob; John; Gendry}
}  

Produces this (not great, but better): enter image description here

sroush
  • 5,375
  • 2
  • 5
  • 11