diff options
author | Jefter Santiago <jeftersmares@gmail.com> | 2022-11-01 13:42:48 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-01 09:42:48 -0700 |
commit | 0f40df58add4263fdb476cbb8e6ad43cd2da900d (patch) | |
tree | c95dda1a65c561c4b210c0fceca7d825a46a91d7 /networkx/algorithms | |
parent | 6096b0993b664028b5bcbc211f1149c8ea9a3957 (diff) | |
download | networkx-0f40df58add4263fdb476cbb8e6ad43cd2da900d.tar.gz |
Improve test coverage for cycles.py (#6152)
* Added test for cycle_basis for graphs with self loops.
* sorted the array for comparision
Diffstat (limited to 'networkx/algorithms')
-rw-r--r-- | networkx/algorithms/tests/test_cycles.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/networkx/algorithms/tests/test_cycles.py b/networkx/algorithms/tests/test_cycles.py index 42a2f017..db62b286 100644 --- a/networkx/algorithms/tests/test_cycles.py +++ b/networkx/algorithms/tests/test_cycles.py @@ -50,6 +50,15 @@ class TestCycles: G = nx.MultiGraph() cy = networkx.cycle_basis(G, 0) + def test_cycle_basis_self_loop(self): + """Tests the function for graphs with self loops""" + G = nx.Graph() + nx.add_cycle(G, [0, 1, 2, 3]) + nx.add_cycle(G, [0, 0, 6, 2]) + cy = nx.cycle_basis(G) + sort_cy = sorted(sorted(c) for c in cy) + assert sort_cy == [[0], [0, 1, 2], [0, 2, 3], [0, 2, 6]] + def test_simple_cycles(self): edges = [(0, 0), (0, 1), (0, 2), (1, 2), (2, 0), (2, 1), (2, 2)] G = nx.DiGraph(edges) |