Skip to content

Commit

Permalink
Clarifies error message in eccentricity
Browse files Browse the repository at this point in the history
Changes the error message when an infinite path length is encountered so
that it is different based on whether the graph is directed or not.
  • Loading branch information
jfinkels committed Oct 30, 2015
1 parent f907b73 commit 6199836
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions networkx/algorithms/distance_measures.py
Expand Up @@ -59,9 +59,14 @@ def eccentricity(G, v=None, sp=None):
except TypeError:
raise networkx.NetworkXError('Format of "sp" is invalid.')
if L != order:
msg = "Graph not connected: infinite path length"
if G.is_directed():
msg = ('Found infinite path length because the digraph is not'
' strongly connected')
else:
msg = ('Found infinite path length because the graph is not'
' connected')
raise networkx.NetworkXError(msg)

e[n]=max(length.values())

if v in G:
Expand Down

0 comments on commit 6199836

Please sign in to comment.