private static int bellmanFord(Vertex pOrigin, int pRoads, int width, int height) {
		HashMap<Vertex, Vertex> predecessors = new HashMap<Vertex, Vertex>();
		HashMap<Vertex, Integer> distances = new HashMap<Vertex, Integer>();
		HashSet<Vertex> visited = new HashSet<Vertex>();
		
		int i, j, result = 0;
		
		for(i = 0; i < collectionVertices.size(); i++) {
			if(collectionVertices.get(i).equals(pOrigin)) {
				distances.put(collectionVertices.get(i), 0);
			} else {
				distances.put(collectionVertices.get(i), INFINITY);
			}
			
			predecessors.put(collectionVertices.get(i), null);
		}
		
		for(i = 0; i < collectionVertices.size()-1; i++) {
			
			for(j = 0; j < pRoads; j++) {
				
				Road aRoad = graph.get(j);
				
				int u = distances.get(aRoad.from); //distance of NodeFrom
				int w = aRoad.time;
				int v = distances.get(aRoad.to); //distance of NodeTo
				
				if(u + w < v) {
					//distances[NodeTo] = distances[NodeFrom] + profit
					distances.put(aRoad.to, u + w);
//					if(predecessors.get(aRoad.to) == null) {
						predecessors.put(aRoad.to, aRoad.from);
//					}
		            
					
				}
				
			}
			
		}
		
		//check for negative cycles
		for(i = 0; i < pRoads; i++) {
			
			Road aRoad = graph.get(i);
			int u = distances.get(aRoad.from); //distance of NodeFrom
			int w = aRoad.time;
			int v = distances.get(aRoad.to); //distance of NodeTo
			
			if(u + w < v) {
				if(reachableFromSource(aRoad.from, predecessors)) {
					result = -1;
				}
				
				
			}
		}
		
		if(result != -1) {
			
			result = distances.get(new Vertex(width-1, height-1));
		
		}
		
		return result;
	}