diff options
author | jfinkels <jfinkels@users.noreply.github.com> | 2015-10-30 11:46:18 -0400 |
---|---|---|
committer | jfinkels <jfinkels@users.noreply.github.com> | 2015-10-30 11:46:18 -0400 |
commit | 619983633e0b67de14973ed2400bc04d5dccdbe1 (patch) | |
tree | 46f1350694a095a0e80a185aa25af337d1033696 | |
parent | f907b7340cc594d4d3513187df9f1523a8769c07 (diff) | |
download | networkx-619983633e0b67de14973ed2400bc04d5dccdbe1.tar.gz |
Clarifies error message in eccentricity
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.
-rw-r--r-- | networkx/algorithms/distance_measures.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/networkx/algorithms/distance_measures.py b/networkx/algorithms/distance_measures.py index f082ad9f..fff1a8e9 100644 --- a/networkx/algorithms/distance_measures.py +++ b/networkx/algorithms/distance_measures.py @@ -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: |