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

Function bfs

networking_flow/minimum_cut.py:13–27  ·  view source on GitHub ↗
(graph, s, t, parent)

Source from the content-addressed store, hash-verified

11
12
13def bfs(graph, s, t, parent):
14 # Return True if there is node that has not iterated.
15 visited = [False] * len(graph)
16 queue = [s]
17 visited[s] = True
18
19 while queue:
20 u = queue.pop(0)
21 for ind in range(len(graph[u])):
22 if visited[ind] is False and graph[u][ind] > 0:
23 queue.append(ind)
24 visited[ind] = True
25 parent[ind] = u
26
27 return visited[t]
28
29
30def mincut(graph, source, sink):

Callers 1

mincutFunction · 0.70

Calls 2

popMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected