8000 BFSWithDepth not calculating depth correctly · Issue #153 · dominikbraun/graph · GitHub
[go: up one dir, main page]

Skip to content

BFSWithDepth not calculating depth correctly #153

Open

Description

@amengcs

The following tree has a single "root" and 5 children attached to that root.
I expected the depth to be 2.

BFSWithDepth increments and passes "depth" to the visit function with values as high as 6.

For this case, it increments depth for the root and again for each child attached to the root as it loops through the adjancency graph.

resourceHash := func(r Resource) string {
return r.Name()
}

s.tree = graph.New(resourceHash, graph.Tree(), graph.Directed(), graph.PreventCycles())
s.tree.AddVertex(NullResource{"root"})
s.tree.AddVertex(NullResource{"A"})
s.tree.AddVertex(NullResource{"B"})
s.tree.AddVertex(NullResource{"C"})
s.tree.AddVertex(NullResource{"D"})
s.tree.AddVertex(NullResource{"E"})
s.tree.AddEdge("root", "A")
s.tree.AddEdge("root", "B")
s.tree.AddEdge("root", "C")
s.tree.AddEdge("root", "D")
s.tree.AddEdge("root", "E")

Activity

  1. amengcs commented on Sep 17, 2023

    @amengcs
    Author

    Using version 0.23.0 (latest)
    It seems like it is returning "width + 1" instead of "depth".

  2. gcpreston commented on Dec 14, 2023

    @gcpreston

    +1 to this 🤕

  3. dominikbraun commented on Feb 28, 2024

    @dominikbraun
    Owner

    First of all, sorry for the late response – I'm going to review #153 today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0