private void relabel(Vertex u) { // System.out.println("Relabeling " + u); assert (u.getExcess() > 0) : "u not overflowing"; List<Vertex> neighbors = u.getNeighbors(); int minHeight = Integer.MAX_VALUE; for (Vertex v : neighbors) { int residCapacity = getResidualCapacity(u, v); assert (residCapacity == 0 || u.getHeight() <= v.getHeight()); if (residCapacity > 0) { int partnerHeight = v.getHeight(); minHeight = partnerHeight < minHeight ? partnerHeight : minHeight; } } u.setHeight(1 + minHeight); }
private void initialize() { Set<Employee> Lset = pp.getEmployees(0); Set<Employee> Rset = pp.getEmployees(1); // FIXME!!! // flow = new HashMap<Vertex, Map<Vertex, Integer>>(2 * (Lset.size() + Rset.size())); // capacity = new HashMap<Vertex, Map<Vertex, Integer>>(2 * (Lset.size() + Rset.size())); flow = new TreeMap<Vertex, Map<Vertex, Integer>>(); capacity = new TreeMap<Vertex, Map<Vertex, Integer>>(); setupSourceSide(Lset); setupSinkSide(Rset); setupLRNeighbors(); biasForFriend(); source.setHeight(V.size() + 2); }