networkx/networkx — pull request #976 by chebee7i (2013-10-16 08:09:31+00:00)
Title: Subtle bug in floyd_warshall_numpy

floyd_warshall_numpy() assumes that the matrix returned by to_numpy_matrix() uses 0 for non-existing edges and replaces these with a np.inf
However, this does not work for edges with weights of 0.

Take this network for example,
(src_node) (dest_node) (edge_weight)
1 2 -2
2 3 -4
1 5 1
5 4 0
4 3 -5
2 5 -7

floyd_warshall_numpy() returns -9 as the shortest of the shortest paths.
floyd_warshall() returns -14 which is the correct answer.

For a quick fix, I modified to_numpy_matrix() to initialise matrices using np.inf and removed floyd_warshall_numpy() code that replaces 0 with inf.
This appeared to work.