Repository navigation
Refactored the working of chordless_cycles to handle self loops - #7901
Conversation
dschult
left a comment
There was a problem hiding this comment.
Nice test -- and I think the changes work -- but include unnecessary extra work. Can you check if the comment/suggestions below work too? Which would you prefer?
|
Thank you for the input @dschult, will check it accordingly! |
|
@dschult Please let me know if I can proceed with this implementation, so I can commit the necessary changes! |
|
You can always make changes to your own PR. No need to ask for permission. |
|
Ack -- I think you replaced the entire list comprehension with
Make sure you can see how this would work before making the changes. Ask if it isn't clear. |
|
We do not report single undirected edges as chordless cycles. We do report parallel undirected edges as chordless 2-cycles: G = nx.MultiGraph([(0, 1), (0, 1)])
list(nx.chordless_cycles(G)) # -> [[1, 0]]I think the "expected_cycles" should write the 2-cycle as |
|
I made the recommended adjustment, but the output remains unchanged. Could the issue be related to how the code handles two-cycles? |
|
Sorry for the delayed response... I eventually found the trouble... I had read the creation of F as ruling out nodes with self-loops. But it didn't. While Hopefully the changes here will help it pass the tests. You will need to "pull" this branch from your fork to your local machine to pick up these changes before you do anything more locally. |
b096fc4 to
279b60f
Compare
279b60f to
a5f823c
Compare
rossbar
left a comment
There was a problem hiding this comment.
LGTM - thanks @akshitasure12 and @dschult ! Yet another instance of a problem that is more complex than it seems at face value - very nice find with unreliable/intermittent tests!

This PR addresses an issue in the
chordless_cyclesfunction where multigraphs with self-loops were not being correctly handled. Added test cases undertest_chordless_cycles_multigraph_self_loopsthat verify :Changes made include :
Addresing issue #7867