title: How to get rank of nodes after processing with Graphviz dot?
body: <p>I use dot to render a graph, and it works ok.</p>
  
  <p>Now I need to somehow <em>get</em> the rank that dot assigned to each node, is there a way to do it?</p>
  
  <p>e.g. from this .dot file:</p>
  
  <pre><code>digraph D {
      Ivan -&gt; Herbert [label="15,16"];
      Ivan -&gt; Diego [label="23", color="slategray"];
      Roberto -&gt; Herbert [label="17,18"];
      Roberto -&gt; Ivan [label="19,20"];
      Diego -&gt; Roberto [label="21", color="slategray", style=dashed, color=red, constraint=false]
      {rank=max;}
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/elwNc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/elwNc.png" alt="dot rendering result"></a></p>
  
  <p>I'd like to get information like:</p>
  
  <pre><code>rank of "Roberto" is 1
  rank of "Ivan" is 2
  rank of "Diego" is 3
  rank of "Herbert" is 3
  </code></pre>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>I'm currently using python but I can use any other tool to achieve this.</p>