java.lang.Object
org.jgrapht.util.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. -
Method Summary
Modifier and Type Method Description java.util.List<V>getIndexList()Get theindexList, a mapping from integers to vertices (i.e.java.util.Map<V,java.lang.Integer>getVertexMap()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 theindexListso it must not be modified.- Parameters:
vertices- the input list of vertices- Throws:
java.lang.NullPointerException- ifverticesisnulljava.lang.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:
java.lang.NullPointerException- ifverticesisnulljava.lang.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
-