diff options
author | Jefter Santiago <jeftersmares@gmail.com> | 2022-11-01 13:42:48 -0300 |
---|---|---|
committer | Jarrod Millman <jarrod.millman@gmail.com> | 2022-11-01 10:29:04 -0700 |
commit | 11d7bf8be5d566bdcd1a93fa25101a5da29f6c9e (patch) | |
tree | 8d8b9de5225fd91dab304f7a710ad058ef3ba09d | |
parent | c817a800f748fe3653913b264fcd4fdab66c030a (diff) | |
download | networkx-11d7bf8be5d566bdcd1a93fa25101a5da29f6c9e.tar.gz |
Improve test coverage for cycles.py (#6152)
* Added test for cycle_basis for graphs with self loops.
* sorted the array for comparision
-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) |