newTarjan returns a tarjan with the sccs field filled with the strongly connected components of the directed graph g.
(g graph)
| 134 | // newTarjan returns a tarjan with the sccs field filled with the |
| 135 | // strongly connected components of the directed graph g. |
| 136 | func newTarjan(g graph) *tarjan { |
| 137 | t := tarjan{ |
| 138 | g: g, |
| 139 | |
| 140 | indexTable: make([]int, len(g)), |
| 141 | lowLink: make([]int, len(g)), |
| 142 | onStack: make([]bool, len(g)), |
| 143 | } |
| 144 | for v := range t.g { |
| 145 | if t.indexTable[v] == 0 { |
| 146 | t.strongconnect(v) |
| 147 | } |
| 148 | } |
| 149 | return &t |
| 150 | } |
| 151 | |
| 152 | // strongconnect is the strongconnect function described in the |
| 153 | // wikipedia article. |
searching dependent graphs…