/** * A recursive method for allocating the level for each vertex. Ensures * that all predecessors of v have a level which is at least one greater * than the level of v. * * @param v the vertex whose minimum level is to be calculated */ public void propagateMinimumLevel(V v) { int level = minLevels.get(v).intValue(); for(V child : getGraph().getPredecessors(v)) { int oldLevel, newLevel; Number o = minLevels.get(child); if (o != null) oldLevel = o.intValue(); else oldLevel = 0; newLevel = Math.max(oldLevel, level + 1); minLevels.put(child, new Integer(newLevel)); if (newLevel > graphHeight) graphHeight = newLevel; propagateMinimumLevel(child); } }
/** * A recursive method for allocating the level for each vertex. Ensures * that all predecessors of v have a level which is at least one greater * than the level of v. * * @param v */ public void propagateMinimumLevel(V v) { int level = minLevels.get(v).intValue(); for(V child : getGraph().getPredecessors(v)) { int oldLevel, newLevel; Number o = minLevels.get(child); if (o != null) oldLevel = o.intValue(); else oldLevel = 0; newLevel = Math.max(oldLevel, level + 1); minLevels.put(child, new Integer(newLevel)); if (newLevel > graphHeight) graphHeight = newLevel; propagateMinimumLevel(child); } }
/** * Had to override this one as well, to ensure that setRoot() is called. */ @Override public void initialize() { super.initialize(); setRoot(getGraph()); }
/** * Calculates the level of each vertex in the graph. Level 0 is * allocated to each vertex with no successors. Level n+1 is allocated to * any vertex whose successors' maximum level is n. */ public void setRoot() { numRoots = 0; Graph<V, E> g = getGraph(); for(V v : g.getVertices()) { if (g.getSuccessors(v).isEmpty()) { setRoot(v); numRoots++; } } }
/** * setRoot calculates the level of each vertex in the graph. Level 0 is * allocated to any vertex with no successors. Level n+1 is allocated to * any vertex whose successors' maximum level is n. */ public void setRoot(Graph<V,E> g) { numRoots = 0; for(V v : g.getVertices()) { Collection<V> successors = getGraph().getSuccessors(v); if (successors.size() == 0) { setRoot(v); numRoots++; } } }
for(V v : getGraph().getVertices()) { if (isLocked(v)) continue;
for(V v : getGraph().getVertices()) { if (isLocked(v)) continue;
@Override public void setSize(Dimension size) { super.setSize(size); for(V v : getGraph().getVertices()) { initializeLocation(v,apply(v),getSize()); } }
@Override public void setSize(Dimension size) { super.setSize(size); for(V v : getGraph().getVertices()) { initializeLocation(v,transform(v),getSize()); } }