Class VertexToIntegerMapping<V>

  • Type Parameters:
    V - the graph vertex type

    public class VertexToIntegerMapping<V>
    extends java.lang.Object
    Helper class for building a one-to-one mapping for a collection of vertices to the integer range $[0, n)$ where $n$ is the number of vertices in the collection.

    This class computes the mapping only once, on instantiation. It does not support live updates.

    Author:
    Alexandru Valeanu
    • Constructor Summary

      Constructors 
      Constructor Description
      VertexToIntegerMapping​(java.util.Collection<V> vertices)
      Create a new mapping from a collection of vertices.
      VertexToIntegerMapping​(java.util.List<V> vertices)
      Create a new mapping from a list of vertices.
      VertexToIntegerMapping​(java.util.Set<V> vertices)
      Create a new mapping from a set of vertices.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<V> getIndexList()
      Get the indexList, a mapping from integers to vertices (i.e.
      java.util.Map<V,​java.lang.Integer> getVertexMap()
      Get the vertexMap, a mapping from vertices to integers (i.e.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • VertexToIntegerMapping

        public VertexToIntegerMapping​(java.util.Set<V> vertices)
        Create a new mapping from a set of vertices.
        Parameters:
        vertices - the input set of vertices
        Throws:
        java.lang.NullPointerException - if vertices is null
      • VertexToIntegerMapping

        public VertexToIntegerMapping​(java.util.List<V> vertices)
        Create a new mapping from a list of vertices. The input list will be used as the indexList so it must not be modified.
        Parameters:
        vertices - the input list of vertices
        Throws:
        java.lang.NullPointerException - if vertices is null
        java.lang.IllegalArgumentException - if the vertices are not distinct
      • VertexToIntegerMapping

        public VertexToIntegerMapping​(java.util.Collection<V> vertices)
        Create a new mapping from a collection of vertices.
        Parameters:
        vertices - the input collection of vertices
        Throws:
        java.lang.NullPointerException - if vertices is null
        java.lang.IllegalArgumentException - if the vertices are not distinct
    • Method Detail

      • getVertexMap

        public java.util.Map<V,​java.lang.Integer> getVertexMap()
        Get the vertexMap, a mapping from vertices to integers (i.e. the inverse of indexList).
        Returns:
        a mapping from vertices to integers
      • getIndexList

        public java.util.List<V> getIndexList()
        Get the indexList, a mapping from integers to vertices (i.e. the inverse of vertexMap).
        Returns:
        a mapping from integers to vertices