title: Is there a way to guarantee hierarchical output from NetworkX?
body: <p>I'm trying to produce a flow diagram of a <strong>tree</strong> structure. I've been able to create representative graphs with networkx, but I need a way to show the <strong>tree</strong> structure when I output a plot. I'm using matplotlib.pylab to plot the graph.</p>
  
  <p>I need to show the data in a structure similar to what is shown <a href="https://graphviz.gitlab.io/_pages/Gallery/directed/Genetic_Programming.html" rel="noreferrer">here</a>. Although I don't have sub-graphs.</p>
  
  <p>How can I guarantee a structure like that?</p>
  
  <p>Examples for the unbelievers:</p>
  
  <p><img src="https://i.stack.imgur.com/QWmUo.png" alt="Various NetworkX layouts"></p>
  
  <p>I've been able to show the graphs with pylab and graphviz, but neither offer the tree structure I'm looking for. I've tried every layout networkx has to offer, but none of them show a <strong>hierarchy</strong>. I've just not sure what <strong>options/mode</strong> to give it <strong>OR</strong> if I need to use weights. Any suggestions would help a bunch.</p>
  
  <p>@jterrace:</p>
  
  <p>Here's a rough outline of what I used to produce the plots above. I've added some labels, but other than that it's the same.</p>
  
  <pre><code>import networkx as nx
  import matplotlib.pyplot as plt
  G = nx.Graph()
  
  G.add_node("ROOT")
  
  for i in xrange(5):
      G.add_node("Child_%i" % i)
      G.add_node("Grandchild_%i" % i)
      G.add_node("Greatgrandchild_%i" % i)
  
      G.add_edge("ROOT", "Child_%i" % i)
      G.add_edge("Child_%i" % i, "Grandchild_%i" % i)
      G.add_edge("Grandchild_%i" % i, "Greatgrandchild_%i" % i)
  
  plt.title("draw_networkx")
  nx.draw_networkx(G)
  
  plt.show()
  </code></pre>