summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDelille Louis <louis.delille@supelec.fr>2021-01-28 09:57:02 +0100
committerDelille Louis <louis.delille@supelec.fr>2021-01-28 09:57:02 +0100
commita1d3eb1a42c1e3953e6631c1d6ced5f9333daee1 (patch)
tree3e0040dc93c12892476d0a8bad5cd608eda27418
parentb26480b1c236a581296c86c7c077600631d3babe (diff)
downloadnetworkx-a1d3eb1a42c1e3953e6631c1d6ced5f9333daee1.tar.gz
added test for max_iter argument
-rw-r--r--networkx/algorithms/community/tests/test_kernighan_lin.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/networkx/algorithms/community/tests/test_kernighan_lin.py b/networkx/algorithms/community/tests/test_kernighan_lin.py
index d11ad864..8ea19008 100644
--- a/networkx/algorithms/community/tests/test_kernighan_lin.py
+++ b/networkx/algorithms/community/tests/test_kernighan_lin.py
@@ -62,3 +62,14 @@ def test_multigraph():
assert_partition_equal(
[A, B], [{mapping[0], mapping[1]}, {mapping[2], mapping[3]}]
)
+
+
+def test_max_iter_argument():
+ G = nx.Graph(
+ [("A", "B", {'weight': 1}), ("A", "C", {'weight': 2}), ("A", "D", {'weight': 3}), ("A", "E", {'weight': 2}),
+ ("A", "F", {'weight': 4}), ("B", "C", {'weight': 1}), ("B", "D", {'weight': 4}), ("B", "E", {'weight': 2}),
+ ("B", "F", {'weight': 1}), ("C", "D", {'weight': 3}), ("C", "E", {'weight': 2}), ("C", "F", {'weight': 1}),
+ ("D", "E", {'weight': 4}), ("D", "F", {'weight': 3}), ("E", "F", {'weight': 2})])
+ partition = ({"A", "B", "C"}, {"D", "E", "F"})
+ C = kernighan_lin_bisection(G, partition, max_iter=1)
+ assert_partition_equal(C, ({"A", "F", "C"}, {"D", "E", "B"}))