title: How to get the shortest path in a weighted graph with NetworkX?
body: <p>I'm trying to get the shortest path in a weighted graph defined as</p>
  <pre class="lang-py prettyprint-override"><code>import networkx as nx
  import matplotlib.pyplot as plt
  g = nx.Graph()
  g.add_edge(131,673,weight=673)
  g.add_edge(131,201,weight=201)
  g.add_edge(673,96,weight=96)
  g.add_edge(201,96,weight=96)
  nx.draw(g,with_labels=True,with_weight=True)
  plt.show()
  </code></pre>
  <p>to do so I use</p>
  <pre><code>nx.shortest_path(g,source=131,target=96)
  </code></pre>
  <p>The expected answer is 131,201,96 because for that path I have the least sum of weights. I'm getting 131,673,96 instead. I tried changing the weights but <code>shortest_path</code> always returns the <em>longest</em> path apparently. What is going on?</p>