MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / dfs

Function dfs

graphs/articulation_points.py:9–30  ·  view source on GitHub ↗
(root, at, parent, out_edge_count)

Source from the content-addressed store, hash-verified

7 is_art = [False] * n
8
9 def dfs(root, at, parent, out_edge_count):
10 if parent == root:
11 out_edge_count += 1
12 visited[at] = True
13 low[at] = at
14
15 for to in graph[at]:
16 if to == parent:
17 pass
18 elif not visited[to]:
19 out_edge_count = dfs(root, to, at, out_edge_count)
20 low[at] = min(low[at], low[to])
21
22 # AP found via bridge
23 if at < low[to]:
24 is_art[at] = True
25 # AP found via cycle
26 if at == low[to]:
27 is_art[at] = True
28 else:
29 low[at] = min(low[at], to)
30 return out_edge_count
31
32 for i in range(n):
33 if not visited[i]:

Callers 1

compute_apFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected