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

Function BFS

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

Source from the content-addressed store, hash-verified

1# Minimum cut on Ford_Fulkerson algorithm.
2
3def BFS(graph, s, t, parent):
4 # Return True if there is node that has not iterated.
5 visited = [False]*len(graph)
6 queue=[]
7 queue.append(s)
8 visited[s] = True
9
10 while queue:
11 u = queue.pop(0)
12 for ind in range(len(graph[u])):
13 if visited[ind] == False and graph[u][ind] > 0:
14 queue.append(ind)
15 visited[ind] = True
16 parent[ind] = u
17
18 return True if visited[t] else False
19
20def mincut(graph, source, sink):
21 # This array is filled by BFS and to store path

Callers 1

mincutFunction · 0.70

Calls 1

popMethod · 0.45

Tested by

no test coverage detected