Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BFSWithDepth not calculating depth correctly #153

Open
amengcs opened this issue Sep 17, 2023 · 3 comments
Open

BFSWithDepth not calculating depth correctly #153

amengcs opened this issue Sep 17, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@amengcs
Copy link

amengcs commented Sep 17, 2023

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")
@amengcs
Copy link
Author

amengcs commented Sep 17, 2023

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

@gcpreston
Copy link

+1 to this 🤕

@dominikbraun
Copy link
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
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants