- java.lang.Object
-
- org.jgrapht.util.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 Summary
Constructors Constructor Description VertexToIntegerMapping(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<V>
getIndexList()
Get theindexList
, a mapping from integers to vertices (i.e.Map<V,Integer>
getVertexMap()
Get thevertexMap
, a mapping from vertices to integers (i.e.
-
-
-
Constructor Detail
-
VertexToIntegerMapping
public VertexToIntegerMapping(List<V> vertices)
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
public VertexToIntegerMapping(Collection<V> vertices)
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
-
-