(graph, s, t, parent)
| 11 | |
| 12 | |
| 13 | def 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 | |
| 30 | def mincut(graph, source, sink): |