org.jgrapht.util

## Class VertexToIntegerMapping<V>

• Type Parameters:
V - the graph vertex type

public class VertexToIntegerMapping<V>
extends 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 Detail

• #### VertexToIntegerMapping

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

public VertexToIntegerMapping(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:
NullPointerException - if vertices is null
IllegalArgumentException - if the vertices are not distinct
• #### VertexToIntegerMapping

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

• #### getVertexMap

public Map<V,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 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