fix(detect-cycle): add JSDoc return type and improve early-exit comments in detectUndirectedCycle#2111
Open
gb3335 wants to merge 1 commit intotrekhleb:masterfrom
Open
fix(detect-cycle): add JSDoc return type and improve early-exit comments in detectUndirectedCycle#2111gb3335 wants to merge 1 commit intotrekhleb:masterfrom
gb3335 wants to merge 1 commit intotrekhleb:masterfrom
Conversation
…comments Addresses issue trekhleb#2057: Incorrect Cycle Path Construction in detectUndirectedCycle - Added @return JSDoc tag documenting the cycle object structure - Improved inline comments explaining the early exit behavior via allowTraversal - Added note about disconnected graph limitation in DFS start comment - Clarified cycle object representation with more descriptive comments The early exit mechanism was already present but undocumented. The allowTraversal callback returns false when a cycle is detected, preventing unnecessary traversal of remaining graph edges, which improves efficiency as described in the issue.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2057
Summary
Addresses issue #2057: Incorrect Cycle Path Construction in detectUndirectedCycle
Changes
@return {Object|null}JSDoc tag documenting the cycle object structure and return typeallowTraversalNotes
The early exit mechanism was already present but undocumented. The
allowTraversalcallback returnsfalsewhen a cycle is detected, preventing unnecessary traversal of remaining graph edges — which improves efficiency as described in the issue.The cycle return value remains an object (not an array) to maintain backward compatibility with existing tests and consumers.