def dfs(self, g: UGraph, i: int, j: int): self.marked[i] = True for node in g.close(i): if not self.marked[node]: self.dfs(g, i, node) elif i != j: self.hasCycle = True
def dfs(self, g: UGraph, v: int): self.marked[v] = True self.id[v] = self.curr_component for node in g.close(v): if not self.marked[node]: self.dfs(g, node)
def dfs(self, g: UGraph, v: int): self.marked[v] = True for node in g.close(v): if not self.marked[node]: self.edgeTo[node] = v self.dfs(g, node)