Skip to content

fix: Cycle.equals() now distinguishes directed cycle direction#49

Open
sauravbhattacharya001 wants to merge 1 commit intomasterfrom
fix/cycle-equals-direction-bug
Open

fix: Cycle.equals() now distinguishes directed cycle direction#49
sauravbhattacharya001 wants to merge 1 commit intomasterfrom
fix/cycle-equals-direction-bug

Conversation

@sauravbhattacharya001
Copy link
Owner

Bug Fix

Problem: CycleAnalyzer.Cycle.equals() compared only vertex sets, so two directed cycles with identical vertices but different traversal orders (e.g., A->B->C->A vs A->C->B->A) were incorrectly considered equal.

Fix: Replaced set-based comparison with canonical rotation form. Cycles are rotated so the lexicographically smallest vertex is first, then compared as ordered lists. Preserves rotation equivalence while distinguishing direction.

Impact: Directed graph cycle analysis now correctly identifies distinct cycles sharing the same vertex set.

Previously, Cycle.equals() compared only the vertex *sets* of two cycles,
meaning two directed cycles with the same vertices but different traversal
orders (e.g., A→B→C→A vs A→C→B→A) would incorrectly be considered equal.
This could cause the cycle enumeration to miss valid distinct cycles in
directed graphs.

Fixed by replacing the set-based comparison with a canonical rotation form:
cycles are rotated so the lexicographically smallest vertex is first, then
compared as ordered lists. This preserves rotation equivalence while
correctly distinguishing different directions.
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions github-actions bot added visualization Graph visualization and UI size/s labels Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s visualization Graph visualization and UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant