title: Calculating shortest path in Networkx given custom edge weight
body: <p>I am trying to assign length property to each edge and based on those lengths calculate the shortest path from node X to node Y. </p>
  
  <p>However, I am not sure how to correctly reference the length properties that I specified in this part of the code:<br>
  <code>nx.shortest_path(G,source='Dehli',target='Pune', weight = ?????)</code> </p>
  
  <h3>Code:</h3>
  
  <pre><code>import matplotlib.pyplot as plt
  G = nx.Graph()
  G.add_nodes_from(["Dehli","Ahmadabad","Kolkata",'Bangalore','Pune','Maduraj'])
  G.add_edge('Dehli', 'Ahmadabad', length =890)
  G.add_edge('Dehli', 'Kolkata', length =1422)
  G.add_edge('Dehli', 'Bangalore', length =2168)
  G.add_edge('Dehli', 'Pune', length =1450)
  G.add_edge('Dehli', 'Maduraj', length = 2603)
  
  G.add_edge('Ahmadabad', 'Kolkata', length =1902)
  G.add_edge('Ahmadabad', 'Bangalore', length =1403)
  G.add_edge('Ahmadabad', 'Pune', length =624)
  G.add_edge('Ahmadabad', 'Maduraj', length =1807)
  G.add_edge('Kolkata', 'Bangalore', length =1778)
  G.add_edge('Kolkata', 'Pune', length =1782)
  G.add_edge('Kolkata', 'Maduraj', length =2043)
  
  G.add_edge('Bangalore', 'Pune', length =824)
  G.add_edge('Bangalore', 'Maduraj', length =404)
  G.add_edge('Pune', 'Maduraj', length =1195)
  
  
  
  nx.draw(G,pos,node_color='k')
  
  path = nx.shortest_path(G,source='Dehli',target='Pune')
  path_edges = zip(path,path[1:])
  nx.draw_networkx_nodes(G,pos,nodelist=path,node_color='g')
  nx.draw_networkx_edges(G,pos,edgelist=path_edges,edge_color='g',width=7)
  print(nx.shortest_path_length(G,source='Dehli',target='Pune'))
  plt.show()
  </code></pre>