java.lang.Object
org.jgrapht.alg.util.VertexDegreeComparator<V,E>
- Type Parameters:
V- the graph vertex typeE- the graph edge type
- All Implemented Interfaces:
Comparator<V>
Compares two vertices based on their degree.
Used by greedy algorithms that need to sort vertices by their degree. Two vertices are considered equal if their degrees are equal.
- Author:
- Linda Buisman
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V> Comparator<V> Returns aComparatorthat compares vertices by their degrees in the specified graph.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
compare, equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Method Details
-
of
Returns aComparatorthat compares vertices by their degrees in the specified graph.The comparator compares in ascending order of degrees (lower degree first). To obtain a comparator that compares in descending order call
Comparator.reversed()on the returned comparator.- Type Parameters:
V- the graph vertex type- Parameters:
g- graph with respect to which the degree is calculated.- Returns:
- a
Comparatorto compare vertices by their degree in ascending order
-