/** * Método recursivo para hacer un recorrido del grafo para obtener el valor de cada * vértice. * * @param v <code>Vertex<StructV></code> */ public boolean recurse(Vertex<StructV> v) { if (v == null) return false; if (v.getValue() == null) return false; if (!(v.getValue().getSprite() instanceof SpriteUnion)) precondition(v); ArrayList<Vertex<StructV>> neighbors = v.getNeighbors(); for (int i = 0; i < neighbors.size(); i++) { Vertex<StructV> tmp = neighbors.get(i); if (tmp == null) break; if (whileCase(tmp)) continue; if (forCase(tmp)) continue; if (ifCase(tmp)) continue; if (unionCase(tmp)) continue; recurse(tmp); } if (!(v.getValue().getSprite() instanceof SpriteIf)) postcondition(v); return false; }
private void computeMatchSet() { for (Vertex v : LV) { for (Vertex neighb : v.getNeighbors()) { if (neighb.getId() != SOURCE_ID && getFlow(v, neighb) > 0) { matches.add(v); matches.add(neighb); } } } }
private void biasForFriend() { Vertex f = Vertex.vertexFromEmployee(Employee.getEmployeeFromId(ProjectParams.FRIEND_ID)); List<Vertex> neighbors = f.getNeighbors(); for (Vertex v : neighbors) { if (flowsForward(v, f)) { v.moveToFrontOfNeighbors(f); } else { v.moveToBackOfNeighbors(f); } } }
private void konigDFS(Set<Vertex> konigSet, Vertex v, boolean edgesInMatch) { if (!konigSet.contains(v)) { konigSet.add(v); for (Vertex neighb : v.getNeighbors()) { if (neighb.getId() != SOURCE_ID && neighb.getId() != SINK_ID) { if (edgesInMatch == (getFlow(v, neighb) > 0 || getFlow(neighb, v) > 0)) { konigDFS(konigSet, neighb, !edgesInMatch); } } } } }
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); }