MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / dfs

Method dfs

graph/lowestcommonancestor.go:42–51  ·  view source on GitHub ↗
(u, par int)

Source from the content-addressed store, hash-verified

40}
41
42func (tree *Tree) dfs(u, par int) {
43 tree.jump[0][u] = par
44 tree.dad[u] = par
45 for _, v := range tree.edges[u] {
46 if v != par {
47 tree.depth[v] = tree.depth[u] + 1
48 tree.dfs(v, u)
49 }
50 }
51}
52
53func (tree *Tree) GetDepth(u int) int {
54 return tree.depth[u]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected