title: How to find the longest path with Python NetworkX?
body: <p>I have a directed graph from S to T.</p>
  
  <p>And I would like to find the route (S, A, C, E, T) and the sum of its capacities (1 + 2 + 3 + 1 = 7) so the sum is the largest.</p>
  
  <p>I tried networkx.algorithms.flow.ford_fulkerson, but I don't know how to get the one-way direction from S to T.</p>
  
  <p>My environment:</p>
  
  <ul>
  <li>Ubuntu 12.04</li>
  <li>Python 2.7.8</li>
  <li>NetworkX 1.9</li>
  <li>Matplotlib 1.4.0</li>
  </ul>
  
  <p>example.py</p>
  
  <pre><code>#!/usr/bin/env python
  # -*- coding: utf-8 -*-
  
  import matplotlib.pylab as p
  import networkx as nx
  
  if __name__ == '__main__':
      DG = nx.DiGraph()
      DG.add_edge('S', 'a', capacity=1)
      DG.add_edge('a', 'b', capacity=1)
      DG.add_edge('a', 'c', capacity=2)
      DG.add_edge('b', 'd', capacity=1)
      DG.add_edge('b', 'e', capacity=2)
      DG.add_edge('c', 'e', capacity=3)
      DG.add_edge('c', 'f', capacity=2)
      DG.add_edge('d', 'T', capacity=1)
      DG.add_edge('e', 'T', capacity=1)
      DG.add_edge('f', 'T', capacity=1)
  
      result = nx.algorithms.flow.ford_fulkerson(DG, 'S', 'T')
      print(result.size(weight='capacity')) # 15.0, but I want 7.
  
      pos = nx.spectral_layout(DG)
      nx.draw(DG, pos)
      nx.draw_networkx_labels(DG, pos)
      nx.draw_networkx_edge_labels(DG, pos)
      p.show()
  
      # This shows a partly bidirectional graph, which is not what I want.
      pos = nx.spectral_layout(result)
      nx.draw(result, pos)
      nx.draw_networkx_labels(result, pos)
      nx.draw_networkx_edge_labels(result, pos)
      p.show()
  </code></pre>