Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Incorrect Cycle Path Construction in detectUndirectedCycle #2057

Open
@Imran-imtiaz48

Description

@Imran-imtiaz48

In the functiondetectUndirectedCycle, the cycle path is being constructed as an object with vertex keys as properties and their parent vertices as values. This makes the returnedcycle not a standard path array, but rather a mapping, which may not be intuitive or useful for consumers expecting an ordered path of vertices forming the cycle. A more conventional approach would be to return anordered array of vertices representing the cycle, starting and ending at the same vertex.
Additionally, if a cycle is detected, the function continues to traverse the graph until DFS completes, although traversal is blocked byallowTraversal once a cycle is set. However, early exit after detecting a cycle could improve efficiency.

Suggested Fix:

  • Changecycle to be an array that accumulates the ordered path of the cycle.
  • Optionally, add a mechanism to exit the traversal immediately after the cycle is found.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp