diff options
author | Stefan van der Walt <stefanv@berkeley.edu> | 2021-01-28 20:34:49 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-28 20:34:49 -0800 |
commit | 5f1d984d5bb850d7c4d8283ba08ed1cdf5f6bab4 (patch) | |
tree | deadd3958aec5940c818378290622dabe406f740 | |
parent | e72316bf295ddab1e60ba22a9a8f381b01337430 (diff) | |
parent | e133f98c55b681aff474412e17551fcefdf4ba7a (diff) | |
download | networkx-5f1d984d5bb850d7c4d8283ba08ed1cdf5f6bab4.tar.gz |
Merge pull request #4575 from ldelille/add-test-kernighan-4415
Add test Kernighan Lin Algorithm
-rw-r--r-- | networkx/algorithms/community/tests/test_kernighan_lin.py | 25 |
1 files changed, 25 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..a452d686 100644 --- a/networkx/algorithms/community/tests/test_kernighan_lin.py +++ b/networkx/algorithms/community/tests/test_kernighan_lin.py @@ -62,3 +62,28 @@ 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"})) |