title: Python: Issues with Networkx Dijkstra algo
body: <p>My objective is to do the exact same thing as posted <a href="http://toreopsahl.com/tnet/weighted-networks/shortest-paths/" rel="nofollow noreferrer">here</a>.</p>
  
  <p>I have a matrix (<code>DataFrame</code> or <code>df</code>) that looks like this:</p>
  
  <pre><code>community A   B   C   D
  A         0   3   4   1
  B         3   0   2   0
  C         4   2   0   1
  D         1   0   1   0 
  </code></pre>
  
  <p>This is a symmetric <code>df</code> and each weight represents the weight or intensity of the connections between each communities. As explained in the link, I want to produce a matrix that shows the shortest distances among all nodes (or communities). I first invert the above matrix and set the <code>G</code> graph network:</p>
  
  <pre><code>G = nx.Graph()
  commu = list(df.index)
  for i in range(0,len(commu)):
      for j in range(0,len(commu)):
              if i == j:
                  pass
              else:
                  G.add_edge(str(i),str(j),weight=df.ix[df.index[i], df.columns[j]])
  </code></pre>
  
  <p>This gives me the following network graph:<img src="https://i.stack.imgur.com/Gwu0g.png" alt="network"> The different colors of the edges is for different weights. (I changed the letters for numbers in my graph)</p>
  
  <p>Ok, so far so good. Now, I want the shortest distance among all nodes. I was thinking to use this <code>nx.dijkstra_shortest_path_length(G,source,target)</code> and loop over all nodes for <code>source</code> and <code>target</code> and produce a matrix like in the above link with all values of the shortest path across all nodes in each cell of the matrix but for some reason <code>nx.dijkstra_shortest_path_length(G,source,target)</code> does not work for me. 
  If I do <code>nx.dijkstra_shortest_path_length(G,A,B)</code> or any combination of nodes, I always get a value of 0. Why? Is there an efficient way of reproducing a matrix like in the link using <code>Networkx</code> and the <code>nx.dijkstra</code> algo?</p>