summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Schult <dschult@colgate.edu>2013-07-22 13:44:32 -0700
committerDan Schult <dschult@colgate.edu>2013-07-22 13:44:32 -0700
commiteba0d369c6ac8bbff199fc96954a2c8734b6e13f (patch)
treee790f17a3c9439bf2253310cdc634844dc2285ea
parent067b7781ffed539b117f35f7a93d1a4a36836d0c (diff)
parentecfc4ea582b577f82b67f35737d931ade3bcb627 (diff)
downloadnetworkx-1.8rc1.tar.gz
Merge pull request #911 from dschult/test_cuts_fixnetworkx-1.8rc1
Make sure graph is connected in test_edge_cutset_random_graphs
-rw-r--r--networkx/algorithms/connectivity/tests/test_cuts.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/networkx/algorithms/connectivity/tests/test_cuts.py b/networkx/algorithms/connectivity/tests/test_cuts.py
index 3211571a..05704947 100644
--- a/networkx/algorithms/connectivity/tests/test_cuts.py
+++ b/networkx/algorithms/connectivity/tests/test_cuts.py
@@ -11,7 +11,7 @@ def _generate_no_biconnected(max_attempts=50):
yield G
else:
if attempts >= max_attempts:
- msg = "Tried %d times: no suitable Graph."
+ msg = "Tried %d times: no suitable Graph."%attempts
raise Exception(msg % max_attempts)
else:
attempts += 1
@@ -138,6 +138,10 @@ def test_node_cutset_random_graphs():
def test_edge_cutset_random_graphs():
for i in range(5):
G = nx.fast_gnp_random_graph(50,0.2)
+ if not nx.is_connected(G):
+ ccs = iter(nx.connected_components(G))
+ start = next(ccs)[0]
+ G.add_edges_from( (start,c[0]) for c in ccs )
cutset = nx.minimum_edge_cut(G)
assert_equal(nx.edge_connectivity(G), len(cutset))
G.remove_edges_from(cutset)