I use dot to render a graph, and it works ok.
Now I need to somehow get the rank that dot assigned to each node, is there a way to do it?
e.g. from this .dot file:
digraph D {
Ivan -> Herbert [label="15,16"];
Ivan -> Diego [label="23", color="slategray"];
Roberto -> Herbert [label="17,18"];
Roberto -> Ivan [label="19,20"];
Diego -> Roberto [label="21", color="slategray", style=dashed, color=red, constraint=false]
{rank=max;}
}
I'd like to get information like:
rank of "Roberto" is 1
rank of "Ivan" is 2
rank of "Diego" is 3
rank of "Herbert" is 3
Where the rank of a node is the depth of it in the graph rendering, i.e. the top node has rank 1, its children 2, etc.
Notice that my graph usually is more complex and always includes cycles, and the visual layout is shown to the user, so a "Do It Yourself" approach is out the table because the rank of each node needs to be the same as the dot rendering.
I'm currently using python but I can use any other tool to achieve this.