public static double[] minCostFlow(ArrayList<Integer> ady[],
				double[][] cap, double[][] cost, int s, int t) {
			int n = cap.length;
			double[] d = new double[n];
			int[] p = new int[n];
			double flowCost = 0;
			int index;
			for (int flow = 0;; ++flow) {
				Arrays.fill(d, Integer.MAX_VALUE);
				d[s] = 0;
				for (int i = 0; i < n; i++)
					for (int j = 0; j < n; j++)
						for (int k = 0; k < ady[j].size(); k++) {
							index = ady[j].get(k);
							if (cap[j][index] > 0 && d[j] < Integer.MAX_VALUE
									&& d[index] > d[j] + cost[j][index]) {
								d[index] = d[j] + cost[j][index];
								p[index] = j;
							}
						}
				if (d[t] == Integer.MAX_VALUE)
					return new double[] { flowCost, flow };
				flowCost += d[t];
				resultado = Math.max(resultado, d[t]);
				for (int v = t; v != s; v = p[v]) {
					--cap[p[v]][v];
					++cap[v][p[v]];
				}
			}

		}