public int[] bellmanFord(int src, List<HashMap<Integer, Integer>> adjList) {
		final int[] dists = new int[adjList.size()];
		int[] prev = new int[adjList.size()];
		Arrays.fill(dists, Integer.MAX_VALUE);
		dists[src] = 0;
		
		for (int i = 0; i < adjList.size(); i++) {
			for (int j = 0; j < adjList.size(); j++)
				for (Integer k: adjList.get(j).keySet())
					if (dists[k] > dists[j] + adjList.get(j).get(k)) {
						dists[k] = dists[j] + adjList.get(j).get(k);
						prev[k] = j;
					}
		}
		
		// check negative cycles
		for (int i = 0; i < adjList.size(); i++) {
			for (Integer j: adjList.get(i).keySet())
				if (dists[j] > dists[i] + adjList.get(i).get(j)) {
					// negative cycle!
				}
		}
		return dists;
	}