java.lang.Object
org.jgrapht.util.VertexToIntegerMapping<V>
- Type Parameters:
V
- the graph vertex type
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
ConstructorDescriptionVertexToIntegerMapping
(Collection<V> vertices) Create a new mapping from a collection of vertices.VertexToIntegerMapping
(List<V> vertices) Create a new mapping from a list of vertices. -
Method Summary
Modifier and TypeMethodDescriptionGet theindexList
, a mapping from integers to vertices (i.e.Get thevertexMap
, a mapping from vertices to integers (i.e.
-
Constructor Details
-
VertexToIntegerMapping
Create a new mapping from a list of vertices. The input list will be used as theindexList
so it must not be modified.- Parameters:
vertices
- the input list of vertices- Throws:
NullPointerException
- ifvertices
isnull
IllegalArgumentException
- if the vertices are not distinct
-
VertexToIntegerMapping
Create a new mapping from a collection of vertices.- Parameters:
vertices
- the input collection of vertices- Throws:
NullPointerException
- ifvertices
isnull
IllegalArgumentException
- if the vertices are not distinct
-
-
Method Details
-
getVertexMap
Get thevertexMap
, a mapping from vertices to integers (i.e. the inverse ofindexList
).- Returns:
- a mapping from vertices to integers
-
getIndexList
Get theindexList
, a mapping from integers to vertices (i.e. the inverse ofvertexMap
).- Returns:
- a mapping from integers to vertices
-