V
 the graph vertex typeE
 the graph edge typepublic class VertexDegreeComparator<V,E> extends Object implements Comparator<V>
Used by greedy algorithms that need to sort vertices by their degree. Two vertices are considered equal if their degrees are equal.
Modifier and Type  Class and Description 

static class 
VertexDegreeComparator.Order
Order in which we sort the vertices: ascending vertex degree or descending vertex degree

Constructor and Description 

VertexDegreeComparator(Graph<V,E> g)
Creates a comparator for comparing the degrees of vertices in the specified graph.

VertexDegreeComparator(Graph<V,E> g,
VertexDegreeComparator.Order order)
Creates a comparator for comparing the degrees of vertices in the specified graph.

Modifier and Type  Method and Description 

int 
compare(V v1,
V v2)
Compare the degrees of
v1 and v2 , taking into account whether
ascending or descending order is used. 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
public VertexDegreeComparator(Graph<V,E> g)
g
 graph with respect to which the degree is calculated.public VertexDegreeComparator(Graph<V,E> g, VertexDegreeComparator.Order order)
g
 graph with respect to which the degree is calculated.order
 order in which the vertices are sorted (ascending or descending)public int compare(V v1, V v2)
v1
and v2
, taking into account whether
ascending or descending order is used.compare
in interface Comparator<V>
v1
 the first vertex to be compared.v2
 the second vertex to be compared.v1
comes before v2
, +1 if
v1
comes after v2
, 0 if equal.Copyright © 2017. All rights reserved.