Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GraphViz Node Placement and Rankdir

Tags:

graphviz

dot

I'm having very good luck with graphviz and have been able to make nearly every graph that I need. I'm trying to duplicate this:

http://en.wikipedia.org/wiki/File:ICS_Structure.PNG

as faithfully as I can. The bottom part of that graph all flows top to bottom and I've got that working fine. What I have not been able to do is place the first 3 children right below "Incident Commander". They branch left and right. Plus note how the edges are shared in the top 8 nodes. Is that possible with dot? I can deal with everything else but not those top nodes. Can someone give me a clue to solve this?

like image 213
simusid Avatar asked Sep 10 '11 19:09

simusid


People also ask

How do you order nodes in Graphviz?

If ordering="out" , then the outedges of a node, that is, edges with the node as its tail node, must appear left-to-right in the same order in which they are defined in the input. If ordering="in" , then the inedges of a node must appear left-to-right in the same order in which they are defined in the input.

What is rank in Graphviz?

Ranks and Subgraphs To work out the layout, Graphviz uses a system it calls "ranks". Each node is assigned a higher rank than the highest ranked node that point to it. If your rank direction is set to left to right ( rankdir=LR ), then nodes with a higher rank are placed further to the right.

How do I use a DOT file in Graphviz?

How do I use graphviz to convert this into an image? For windows: dl the msi and install; Find gvedit.exe in your programs list; Open . dot file in question; Click running person on toolbar; Go to graph -> settings ; change Output file type to file type of your liking and press ok..


1 Answers

Two useful techniques for reproducing graph layouts are:

  • Invisible nodes
  • Rank constraints

Here's a quick try for the top nodes:

digraph g{ ranksep=0.2;  node[shape=box3d, width=2.3, height=0.6, fontname="Arial"]; n1[label="Incident Commander"]; n2[label="Public Information\nOfficer"]; n3[label="Liaison Officer"]; n4[label="Safety Officer"]; n5[label="Operations Section"]; n6[label="Planning Section"]; n7[label="Logistics Section"]; n8[label="Finance/Admin. Section"];  node[shape=none, width=0, height=0, label=""]; edge[dir=none]; n1 -> p1 -> p2 -> p3; {rank=same; n2 -> p1 -> n3;} {rank=same; n4 -> p2;} {rank=same; p4 -> p5 -> p3 -> p6 -> p7;} p4 -> n5; p5 -> n6; p6 -> n7; p7 -> n8; } 

And here's the result:

dot layout top nodes

like image 107
marapet Avatar answered Oct 05 '22 04:10

marapet