diff options
author | Dan Schult <dschult@colgate.edu> | 2018-07-08 21:13:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-08 21:13:11 -0400 |
commit | 7c016c49a8e5f9f5bf46406633ed27f5c74ae768 (patch) | |
tree | 6e7fd483509ceaca7bcd54872a1b311faf3f2aa9 /networkx/algorithms/connectivity/edge_augmentation.py | |
parent | fbce5c9a6fcc473d27240fd218db1378c6b38d34 (diff) | |
download | networkx-7c016c49a8e5f9f5bf46406633ed27f5c74ae768.tar.gz |
Pull request to set up python3.7 testing on travis (#3054)
* Fix StopIteration handling which breaks in python 3.7
Fixes #3046
* Shift from testing py3.4 to py3.7 in travis
* Allow failures on python 3.7
* Try testing py37-dev version
Diffstat (limited to 'networkx/algorithms/connectivity/edge_augmentation.py')
-rw-r--r-- | networkx/algorithms/connectivity/edge_augmentation.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/networkx/algorithms/connectivity/edge_augmentation.py b/networkx/algorithms/connectivity/edge_augmentation.py index 326478e8..67f8708e 100644 --- a/networkx/algorithms/connectivity/edge_augmentation.py +++ b/networkx/algorithms/connectivity/edge_augmentation.py @@ -813,7 +813,10 @@ def unconstrained_bridge_augmentation(G): A2 = [tuple(leafs)] else: # Choose an arbitrary non-leaf root - root = next(n for n, d in T.degree() if d > 1) + try: + root = next(n for n, d in T.degree() if d > 1) + except StopIteration: # no nodes found with degree > 1 + return # order the leaves of C by (induced directed) preorder v2 = [n for n in nx.dfs_preorder_nodes(T, root) if T.degree(n) == 1] # connecting first half of the leafs in pre-order to the second @@ -954,7 +957,10 @@ def weighted_bridge_augmentation(G, avail, weight=None): # nx.least_common_ancestor on the reversed Tree. # Pick an arbitrary leaf from C as the root - root = next(n for n in C.nodes() if C.degree(n) == 1) + try: + root = next(n for n, d in C.degree() if d == 1) + except StopIteration: # no nodes found with degree == 1 + return # Root C into a tree TR by directing all edges away from the root # Note in their paper T directs edges towards the root TR = nx.dfs_tree(C, root) @@ -1230,7 +1236,7 @@ def greedy_k_edge_augmentation(G, k, avail=None, weight=None, seed=None): done = is_k_edge_connected(G, k) if done: - raise StopIteration() + return if avail is None: # all edges are available avail_uv = list(complement_edges(G)) |