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

Function dfs

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

Source from the content-addressed store, hash-verified

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

Callers 1

computeAPFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected