Traverse performs a depth-first traversal of the graph starting from the node
(visited map[string]bool)
| 34 | |
| 35 | // Traverse performs a depth-first traversal of the graph starting from the node |
| 36 | func (n *Node) Traverse(visited map[string]bool) { |
| 37 | if visited[n.id] { |
| 38 | return |
| 39 | } |
| 40 | |
| 41 | visited[n.id] = true |
| 42 | log.Printf("Visiting node %s", n.id) |
| 43 | |
| 44 | for _, neighbor := range n.neighbors { |
| 45 | neighbor.Traverse(visited) |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | // TraverseConcurrently performs a concurrent depth-first traversal of the graph starting from the node |
| 50 | func (n *Node) TraverseConcurrently(visited map[string]bool, wg *sync.WaitGroup) { |