Node placement in family tree visualization with Dot/Graphviz -
i'm trying generate family tree visualizations database using dot/graphviz. first results promising, there 1 layout issue haven't been able fix yet.
when use code listed below, produce
i'm totally happy this. try add node between families f4/m4/m5 , f2/m2, can done uncommenting 2 lines in code below, give me
male2 placed far away female2 , between female4 , male4. families f2/m2 , f4/m4/m5 torn apart. tried increase weight family connections (value 100) in order make sure families f2/m2 , f4/m4/m5 placed together, doesn't work. changing order of nodes or connections did not far. best solution be, if family f4/m4/m5 placed on left, malex in center , family f2/m2 on right.
does have suggestion? prefer not change order in nodes , connections defined in code, because done script , kind of predefined database structure.
graph test { rankdir = bt; splines = ortho; center = true; { rank = same; nodefemale1 [label = female1]; nodemale1 [label = male1]; connectionfemale1male1 [shape = box, label = "", height = 0, width = 1, margin = 0, penwidth = 1]; nodefemale1 -- connectionfemale1male1 -- nodemale1 [weight = 100, penwidth = 2]; } connectionchildren11 [shape = box, label = "", height = 0, width = 0, margin = 0, penwidth = 1]; connectionfemale1male1 -- connectionchildren11 [penwidth = 2]; { rank = same; nodefemale2 [label = female2]; nodemale2 [label = male2]; connectionfemale2male2 [shape = box, label = "", height = 0, width = 0, margin = 0, penwidth = 1]; nodefemale2 -- connectionfemale2male2 -- nodemale2 [weight = 100, penwidth = 2]; } connectionchildren11 -- nodemale2 [penwidth = 2]; connectionchildren22 [shape = box, label = "", height = 0, width = 0, margin = 0, penwidth = 1]; connectionfemale2male2 -- connectionchildren22 [penwidth = 2]; nodemale3 [label = male3]; connectionchildren22 -- nodemale3 [weight = 10, penwidth = 2]; nodefemale3 [label = female3]; connectionchildren22 -- nodefemale3 [penwidth = 2]; // nodemalex [label = malex]; // connectionchildren11 -- nodemalex [weight = 10, penwidth = 2]; { rank = same; nodefemale4 [label = female4]; nodemale4 [label = male4]; nodemale5 [label = male5]; connectionfemale4male4 [shape = box, label = "", height = 0, width = 0, margin = 0, penwidth = 1]; nodefemale4 -- connectionfemale4male4 -- nodemale4 [weight = 100, penwidth = 2]; connectionmale4male5 [shape = box, label = "", height = 0, width = 0, margin = 0, penwidth = 1]; nodemale4 -- connectionmale4male5 -- nodemale5 [weight = 100, penwidth = 2]; } connectionchildren11 -- nodefemale4 [penwidth = 2]; connectionchildren44 [shape = box, label = "", height = 0, width = 0, margin = 0, penwidth = 1]; connectionfemale4male4 -- connectionchildren44 [penwidth = 2]; nodefemale6 [label = female6]; connectionchildren44 -- nodefemale6 [weight = 10, penwidth = 2]; nodefemale7 [label = female7]; connectionchildren44 -- nodefemale7 [penwidth = 2]; connectionchildren45 [shape = box, label = "", height = 0, width = 0, margin = 0, penwidth = 1]; connectionmale4male5 -- connectionchildren45 [penwidth = 2]; nodefemale8 [label = female8]; connectionchildren45 -- nodefemale8 [penwidth = 2]; }
i don't think can take control way want without resorting subgraph
. may or may not helpful in context of script , database provides nodes , edges have tried comes close want:
graph test { /* layout / format */ rankdir = bt; // bottoms top splines = ortho; // edges orthogonal center = true; // page center edge [ penwidth = 2 ]; // edge thickness node [ width = 1.1 ]; // conistent node size /* node , edge definitions produced script (?) */ nodefemale1 [label = female1]; nodemale1 [label = male1]; connectionfemale1male1 [shape = box, label = "", height = 0, width = 1, margin = 0, penwidth = 1]; // 1 nodefemale1 -- connectionfemale1male1 -- nodemale1 [weight = 100, penwidth = 2]; connectionchildren11 [shape = box, label = "", height = 0, width = 0, margin = 0, penwidth = 1]; // 2 connectionfemale1male1 -- connectionchildren11 [penwidth = 2]; nodefemale2 [label = female2]; nodemale2 [label = male2]; connectionfemale2male2 [shape = box, label = "", height = 0, width = 0, margin = 0, penwidth = 1]; // 3 nodefemale2 -- connectionfemale2male2 -- nodemale2 [weight = 100, penwidth = 2]; // 4 connectionchildren11 -- nodemale2 [penwidth = 2]; connectionchildren22 [shape = box, label = "", height = 0, width = 0, margin = 0, penwidth = 1]; // 5 connectionfemale2male2 -- connectionchildren22 [penwidth = 2]; nodemale3 [label = male3]; // 6 connectionchildren22 -- nodemale3 [weight = 10, penwidth = 2]; nodefemale3 [label = female3]; // 7 connectionchildren22 -- nodefemale3 [penwidth = 2]; nodemalex [label = malex]; // 8 connectionchildren11 -- nodemalex [weight = 10, penwidth = 2]; nodefemale4 [label = female4]; nodemale4 [label = male4]; nodemale5 [label = male5]; connectionfemale4male4 [shape = box, label = "", height = 0, width = 0, margin = 0, penwidth = 1]; // 9 nodefemale4 -- connectionfemale4male4 -- nodemale4 [weight = 100, penwidth = 2]; connectionmale4male5 [shape = box, label = "", height = 0, width = 0, margin = 0, penwidth = 1]; // 10 nodemale4 -- connectionmale4male5 -- nodemale5 [weight = 100, penwidth = 2]; // 11 connectionchildren11 -- nodefemale4 [penwidth = 2]; connectionchildren44 [shape = box, label = "", height = 0, width = 0, margin = 0, penwidth = 1]; // 12 connectionfemale4male4 -- connectionchildren44 [penwidth = 2]; nodefemale6 [label = female6]; // 13 connectionchildren44 -- nodefemale6 [weight = 10, penwidth = 2]; nodefemale7 [label = female7]; // 14 connectionchildren44 -- nodefemale7 [penwidth = 2]; connectionchildren45 [shape = box, label = "", height = 0, width = 0, margin = 0, penwidth = 1]; // 15 connectionmale4male5 -- connectionchildren45 [penwidth = 2]; nodefemale8 [label = female8]; // 16 connectionchildren45 -- nodefemale8 [penwidth = 2]; /* family / generation subgraphs */ subgraph cluster0 { style = filled; fillcolor = lightgrey; color = white; { rank = same; nodefemale1; connectionfemale1male1; nodemale1 } nodefemale1 -- connectionfemale1male1 -- nodemale1; } connectionfemale1male1 -- connectionchildren11; subgraph cluster1 { { rank = same; nodemale2; connectionfemale2male2; nodefemale2 } nodefemale2 -- connectionfemale2male2 -- nodemale2; } connectionchildren11 -- nodemale2; subgraph cluster2 { nodemalex; } connectionchildren11 -- nodemalex; subgraph cluster3 { { rank = same; nodefemale4; nodemale4; nodemale5; connectionfemale4male4; connectionmale4male5 } nodefemale4 -- connectionfemale4male4 -- nodemale4 -- connectionmale4male5 -- nodemale5; } connectionchildren11 -- nodefemale4; subgraph cluster4 { color = white; { rank = same; nodemale3; nodefemale3 } } connectionfemale2male2 --connectionchildren22; connectionchildren22 -- { nodemale3 nodefemale3 }; subgraph cluster5 { color = white; { rank = same; nodefemale6; nodefemale7 } } connectionfemale4male4 --connectionchildren44; connectionchildren44 -- { nodefemale6 nodefemale7 }; subgraph cluster6 { color = white; nodefemale8; } connectionmale4male5 --connectionchildren45; connectionchildren45 -- nodefemale8; }
the clusters can customized, demonstrated on parents level. if set color = white
become "invisible", shown in grandchildren generation.
Comments
Post a Comment