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

Function BFS

networking_flow/ford_fulkerson.py:8–23  ·  view source on GitHub ↗
(graph, s, t, parent)

Source from the content-addressed store, hash-verified

6"""
7
8def BFS(graph, s, t, parent):
9 # Return True if there is node that has not iterated.
10 visited = [False]*len(graph)
11 queue=[]
12 queue.append(s)
13 visited[s] = True
14
15 while queue:
16 u = queue.pop(0)
17 for ind in range(len(graph[u])):
18 if visited[ind] == False and graph[u][ind] > 0:
19 queue.append(ind)
20 visited[ind] = True
21 parent[ind] = u
22
23 return True if visited[t] else False
24
25def FordFulkerson(graph, source, sink):
26 # This array is filled by BFS and to store path

Callers 1

FordFulkersonFunction · 0.70

Calls 1

popMethod · 0.45

Tested by

no test coverage detected