Class RatioVertex<V>

  • Type Parameters:
    V - the graph vertex type
    All Implemented Interfaces:

    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.
    Joris Kinable
    • Field Detail

      • v

        public final V v
        original vertex
      • weight

        public double weight
        weight of the vertex
      • 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
        ID - unique id
        v - the vertex
        weight - the vertex weight
    • Method Detail

      • addNeighbor

        public void addNeighbor​(RatioVertex<V> v)
        Add a neighbor.
        v - the neighbor
      • removeNeighbor

        public void removeNeighbor​(RatioVertex<V> v)
        Remove a neighbor.
        v - the neighbor to remove
      • getDegree

        public int getDegree()
        Returns the degree of the vertex
        degree of the vertex
      • getRatio

        public double getRatio()
        Returns the ratio between the vertex' weight and its degree
        the ratio between the vertex' weight and its degree
      • hashCode

        public int hashCode()
        hashCode in class Object