Skip to content

fixed cycle detection in exists_directed_cycle#255

Merged
kunwuz merged 1 commit intopy-why:mainfrom
maxhahn:patch-1
Mar 27, 2026
Merged

fixed cycle detection in exists_directed_cycle#255
kunwuz merged 1 commit intopy-why:mainfrom
maxhahn:patch-1

Conversation

@maxhahn
Copy link
Copy Markdown
Contributor

@maxhahn maxhahn commented Mar 16, 2026

The cycle detection is broken, since the case c==node_to can never be reached since c in V comes before, which is true when node_from==node_to as is the case with the cycle check.

Please let me know if I am mistaken, but a simple graph A->B->C and C->A was determined to have no cycle without this fix.

with c in V continue, this will never be able to detect cycles where node_from == node_to, since node_from is always in V, thereby continuing when c == node_to (since c in V takes precedent)

Signed-off-by: Max Hahn <40292613+maxhahn@users.noreply.github.com>
@kunwuz
Copy link
Copy Markdown
Collaborator

kunwuz commented Mar 27, 2026

Thank you so much for your fix!

@kunwuz kunwuz self-assigned this Mar 27, 2026
@kunwuz kunwuz self-requested a review March 27, 2026 03:47
@kunwuz kunwuz merged commit b879e57 into py-why:main Mar 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants