MCPcopy Create free account
hub / github.com/KOSASIH/skybridge / TraverseConcurrently

Method TraverseConcurrently

src/node/node.go:50–69  ·  view source on GitHub ↗

TraverseConcurrently performs a concurrent depth-first traversal of the graph starting from the node

(visited map[string]bool, wg *sync.WaitGroup)

Source from the content-addressed store, hash-verified

48
49// TraverseConcurrently performs a concurrent depth-first traversal of the graph starting from the node
50func (n *Node) TraverseConcurrently(visited map[string]bool, wg *sync.WaitGroup) {
51 defer wg.Done()
52
53 if visited[n.id] {
54 return
55 }
56
57 visited[n.id] = true
58 log.Printf("Visiting node %s", n.id)
59
60 var neighborWgs sync.WaitGroup
61 for _, neighbor := range n.neighbors {
62 neighborWgs.Add(1)
63 go func(neighbor *Node) {
64 neighbor.TraverseConcurrently(visited, &neighborWgs)
65 }(neighbor)
66 }
67
68 neighborWgs.Wait()
69}

Callers 1

TestNodeFunction · 0.95

Calls

no outgoing calls

Tested by 1

TestNodeFunction · 0.76