| Conditions | 5 |
| Total Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | from pyalgs.data_structures.commons.stack import Stack |
||
| 12 | def __init__(self, G): |
||
| 13 | if isinstance(G, DirectedEdgeWeightedGraph): |
||
| 14 | G = G.to_digraph() |
||
| 15 | |||
| 16 | if not isinstance(G, Digraph): |
||
| 17 | raise ValueError('Graph must be unweighted digraph') |
||
| 18 | |||
| 19 | vertex_count = G.vertex_count() |
||
| 20 | self.marked = [False] * vertex_count |
||
| 21 | self.onStack = [False] * vertex_count |
||
| 22 | self.edgeTo = [-1] * vertex_count |
||
| 23 | |||
| 24 | for v in range(vertex_count): |
||
| 25 | if not self.marked[v]: |
||
| 26 | self.dfs(G, v) |
||
| 27 | |||
| 55 |