]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
python/kcc/graph_utils: short-cut edge failure test without edges
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Sat, 9 Jun 2018 08:07:37 +0000 (20:07 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Sun, 10 Jun 2018 17:02:19 +0000 (19:02 +0200)
Otherwise we get an exception because itertools.combinations is asked
to find combinations with negative size.

Instead we assert the graph is connected as-is, which in this case is
the same as asserting there are no vertices.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/kcc/graph_utils.py

index 727b342d4bbe2902bc453032fe460101512f24a5..65f5ee672074eb230917501538f82c3435eb3e6d 100644 (file)
@@ -93,6 +93,9 @@ def verify_graph_connected(edges, vertices, edge_vertices):
 
 def verify_graph_connected_under_edge_failures(edges, vertices, edge_vertices):
     """The graph stays connected when any single edge is removed."""
+    if len(edges) == 0:
+        return verify_graph_connected(edges, vertices, edge_vertices)
+
     for subset in itertools.combinations(edges, len(edges) - 1):
         try:
             verify_graph_connected(subset, vertices, edge_vertices)