public static int edmons_karp(int source, int finish) {
		int u;
		mf = 0;
		s = source;
		t = finish;
		while (true) {
			f = 0;
			Queue<Integer> q = new LinkedList<Integer>();
			ArrayList<Integer> dist = new ArrayList<Integer>();
			dist.addAll(Collections.nCopies(V, INF));
			dist.set(s, 0);
			q.offer(s);

			p.clear();
			p.addAll(Collections.nCopies(V, -1));

			while (!q.isEmpty()) {
				u = q.poll();
				if (u == t)
					break;
				for (int i = 0; i < V; i++) {
					if (i < dist.size() && dist != null && g[u][i] > 0
							&& dist.get(i) == INF) {
						dist.set(i, dist.get(u) + 1);
						q.add(i);
						p.set(i, u);// parent of vertex i is vertex u
					}
				}
			}
			augment(t, INF);
			if (f == 0)
				break;
			mf += f;
		}
		return mf;
	}