(int Graph[][], int s, int t, int p[])
| 7 | |
| 8 | // Using BFS as a searching algorithm |
| 9 | boolean bfs(int Graph[][], int s, int t, int p[]) { |
| 10 | boolean visited[] = new boolean[V]; |
| 11 | for (int i = 0; i < V; ++i) |
| 12 | visited[i] = false; |
| 13 | |
| 14 | LinkedList<Integer> queue = new LinkedList<Integer>(); |
| 15 | queue.add(s); |
| 16 | visited[s] = true; |
| 17 | p[s] = -1; |
| 18 | |
| 19 | while (queue.size() != 0) { |
| 20 | int u = queue.poll(); |
| 21 | |
| 22 | for (int v = 0; v < V; v++) { |
| 23 | if (visited[v] == false && Graph[u][v] > 0) { |
| 24 | queue.add(v); |
| 25 | p[v] = u; |
| 26 | visited[v] = true; |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | return (visited[t] == true); |
| 32 | } |
| 33 | |
| 34 | // Applying fordfulkerson algorithm |
| 35 | int fordFulkerson(int graph[][], int s, int t) { |
no test coverage detected