Function
dfs
(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]: |
Tested by
no test coverage detected