- java.lang.Object
-
- org.jgrapht.alg.vertexcover.util.RatioVertex<V>
-
- Type Parameters:
V- the graph vertex type
- All Implemented Interfaces:
Comparable<RatioVertex<V>>
public class RatioVertex<V> extends Object implements Comparable<RatioVertex<V>>
Helper class for vertex covers. Guarantees that vertices can be sorted, thereby obtaining a unique ordering.- Author:
- Joris Kinable
-
-
Field Summary
Fields Modifier and Type Field Description protected intdegreedegree of this vertexintidunique id, used to guarantee that compareTo never returns 0intIDDeprecated, for removal: This API element is subject to removal in a future version.useidinsteadMap<RatioVertex<V>,Integer>neighborsMap of neighbors, and a count of the number of edges to this neighborVvoriginal vertexdoubleweightweight of the vertex
-
Constructor Summary
Constructors Constructor Description RatioVertex(int id, V v, double weight)Create a new ratio vertex
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddNeighbor(RatioVertex<V> v)Add a neighbor.intcompareTo(RatioVertex<V> other)booleanequals(Object o)intgetDegree()Returns the degree of the vertexdoublegetRatio()Returns the ratio between the vertex' weight and its degreeinthashCode()voidremoveNeighbor(RatioVertex<V> v)Remove a neighbor.StringtoString()
-
-
-
Field Detail
-
v
public final V v
original vertex
-
weight
public double weight
weight of the vertex
-
ID
@Deprecated(since="1.5.2", forRemoval=true) public final int ID
Deprecated, for removal: This API element is subject to removal in a future version.useidinsteadunique id, used to guarantee that compareTo never returns 0
-
id
public final int id
unique id, used to guarantee that compareTo never returns 0
-
degree
protected int degree
degree of this vertex
-
neighbors
public final Map<RatioVertex<V>,Integer> neighbors
Map of neighbors, and a count of the number of edges to this neighbor
-
-
Constructor Detail
-
RatioVertex
public RatioVertex(int id, V v, double weight)Create a new ratio vertex- Parameters:
id- unique idv- the vertexweight- the vertex weight
-
-
Method Detail
-
addNeighbor
public void addNeighbor(RatioVertex<V> v)
Add a neighbor.- Parameters:
v- the neighbor
-
removeNeighbor
public void removeNeighbor(RatioVertex<V> v)
Remove a neighbor.- Parameters:
v- the neighbor to remove
-
getDegree
public int getDegree()
Returns the degree of the vertex- Returns:
- degree of the vertex
-
getRatio
public double getRatio()
Returns the ratio between the vertex' weight and its degree- Returns:
- the ratio between the vertex' weight and its degree
-
compareTo
public int compareTo(RatioVertex<V> other)
- Specified by:
compareToin interfaceComparable<V>
-
-