/** * Had to override this one as well, to ensure that setRoot() is called. */ @Override public void initialize() { super.initialize(); setRoot(); }
/** * 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++; } } }