(graph, s, t, parent)
| 6 | """ |
| 7 | |
| 8 | def 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 | |
| 25 | def FordFulkerson(graph, source, sink): |
| 26 | # This array is filled by BFS and to store path |