GraphUtil { public static <V extends IVertex, E extends IEdge<V>> Iterable<V> getVerticesSortedByDegree (IGraph<V, E> graph, EDegree mode, boolean bSortAscending) { List<VertexWithDegree<V, E>> listVertices = (List<VertexWithDegree<V, E>>) GraphUtil.getVerticesWithDegree (graph, mode); Collections.sort (listVertices, new VertexDegreeComparator<V, E, VertexWithDegree<V, E>> (bSortAscending)); List<V> list = new ArrayList<> (graph.getVerticesCount ()); for (VertexWithDegree<V, E> vertex : listVertices) list.add (vertex.getVertex ()); return list; }  static Collection<V> getRootVertices(IGraph<V, E> graph); static Collection<V> getLeafVertices(IGraph<V, E> graph); static Collection<V> getSuccessors(IGraph<V, E> graph, V vertex); static Collection<V> getPredecessors(IGraph<V, E> graph, V vertex); static Collection<V> getNeighbors(IGraph<V, E> graph, V vertex); static int getDegree(IGraph<V, E> graph, V vertex, EDegree mode); static Iterable<VertexWithDegree<V, E>> getVerticesWithDegree(IGraph<V, E> graph, EDegree mode); static Iterable<V> getVerticesSortedByDegree(IGraph<V, E> graph, EDegree mode, boolean bSortAscending); static IVertex[] getTopologicalSort(IGraph<V, E> graph); static boolean isTopologicalOrder(IGraph<V, E> graph, Iterable<V> listVertices);  }
@Test public void testGetVerticesSortedByDegree () { int nLastDegree = -1; for (Vertex v : GraphUtil.getVerticesSortedByDegree (m_graph, EDegree.IN_DEGREE, true)) { int nDegree = GraphUtil.getDegree (m_graph, v, EDegree.IN_DEGREE); if (nLastDegree >= 0) assertEquals (true, nLastDegree <= nDegree); nLastDegree = nDegree; } }