GetUpstream returns all tasks that the given task depends on (transitively)
(taskID string)
| 109 | |
| 110 | // GetUpstream returns all tasks that the given task depends on (transitively) |
| 111 | func (g *Graph) GetUpstream(taskID string) map[string]bool { |
| 112 | visited := make(map[string]bool) |
| 113 | var visit func(id string) |
| 114 | visit = func(id string) { |
| 115 | if visited[id] { |
| 116 | return |
| 117 | } |
| 118 | visited[id] = true |
| 119 | for _, depID := range g.RevAdjacency[id] { |
| 120 | visit(depID) |
| 121 | } |
| 122 | } |
| 123 | visit(taskID) |
| 124 | delete(visited, taskID) // Don't include the root task itself |
| 125 | return visited |
| 126 | } |
| 127 | |
| 128 | // DetectCycles finds all cycles in the graph |
| 129 | // |
no outgoing calls