Interface IndexIntIdMap
-
- All Superinterfaces:
IndexIdMap<Integer>
public interface IndexIntIdMap extends IndexIdMap<Integer>
A mapping betweenIntGraph
IDs toIndexGraph
indices.This interface is a specific version of
IndexIdMap
forIntGraph
.A regular graph contains vertices and edges which are identified by a fixed
int
IDs. AnIndexGraph
view is provided by theGraph.indexGraph()
method, which is a graph in which all methods are accessed with indices rather than fixed IDs. This interface maps between the indices and the fixed IDs of the graph vertices or edges.Note that the mapping may change during the graph lifetime, as vertices and edges are added and removed from the graph, and a regular graph IDs are fixed, while a index graph indices are always
(0,1,2, ...,verticesNum-1)
and(0,1,2, ...,edgesNum-1)
. The mapping object will be updated automatically in such cases.The mapping interface is used for both vertices and edges, and we use a unify term element in the documentation to describe both of them. If the mapping was obtained by
IntGraph.indexGraphVerticesMap()
it will map between vertices IDs and indices, and if it was obtained byIntGraph.indexGraphEdgesMap()
it will map between edges IDs and indices.- Author:
- Barak Ugav
- See Also:
IndexGraph
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description static IndexIntIdMap
identityEdgesMap(IntSet edgeSet)
Create an identity mapping between the elements IDs and indices.static IndexIntIdMap
identityVerticesMap(IntSet vertexSet)
Create an identity mapping between the elements IDs and indices.int
idToIndex(int id)
Get the index of an element by its ID.default int
idToIndex(Integer id)
Deprecated.Please useidToIndex(int)
instead to avoid un/boxing.int
idToIndexIfExist(int id)
Get the index of an element by its identifier if it exists, or-1
if it doesn't.default int
idToIndexIfExist(Integer id)
Deprecated.Please useidToIndexIfExist(int)
instead to avoid un/boxing.default Integer
indexToId(int index)
Deprecated.Please useindexToIdInt(int)
instead to avoid un/boxing.default Integer
indexToIdIfExist(int index)
Deprecated.Please useindexToIdIfExistInt(int)
instead to avoid un/boxing.int
indexToIdIfExistInt(int index)
Get the identifier of an element by its index if it exists, or-1
if it doesn't.int
indexToIdInt(int index)
Get the ID of an element by its index.
-
-
-
Method Detail
-
indexToIdInt
int indexToIdInt(int index)
Get the ID of an element by its index.Whether this method maps vertices or edges depends if the mapping object was obtained by
IntGraph.indexGraphVerticesMap()
orIntGraph.indexGraphEdgesMap()
.- Parameters:
index
- an index of an element (vertex/edge)- Returns:
- the ID of the element
- Throws:
IndexOutOfBoundsException
- ifindex
is not in range[, elementsNum)
whereelementsNum
is the number of either vertices or edges, depending on the context
-
indexToId
@Deprecated default Integer indexToId(int index)
Deprecated.Please useindexToIdInt(int)
instead to avoid un/boxing.Get the identifier of an element by its index.Whether this method maps vertices or edges depends if the mapping object was obtained by
Graph.indexGraphVerticesMap()
orGraph.indexGraphEdgesMap()
.- Specified by:
indexToId
in interfaceIndexIdMap<Integer>
- Parameters:
index
- an index of an element (vertex/edge)- Returns:
- the identifier of the element
-
indexToIdIfExistInt
int indexToIdIfExistInt(int index)
Get the identifier of an element by its index if it exists, or-1
if it doesn't.Whether this method maps vertices or edges depends if the mapping object was obtained by
Graph.indexGraphVerticesMap()
orGraph.indexGraphEdgesMap()
.- Parameters:
index
- the index of an element (vertex/edge)- Returns:
- the identifier of the element, or
-1
if there is not such element
-
indexToIdIfExist
@Deprecated default Integer indexToIdIfExist(int index)
Deprecated.Please useindexToIdIfExistInt(int)
instead to avoid un/boxing.Get the identifier of an element by its index if it exists, ornull
if it doesn't.Whether this method maps vertices or edges depends if the mapping object was obtained by
Graph.indexGraphVerticesMap()
orGraph.indexGraphEdgesMap()
.- Specified by:
indexToIdIfExist
in interfaceIndexIdMap<Integer>
- Parameters:
index
- the index of an element (vertex/edge)- Returns:
- the identifier of the element, or
null
if there is not such element
-
idToIndex
int idToIndex(int id)
Get the index of an element by its ID.Whether this method maps vertices or edges depends if the mapping object was obtained by
IntGraph.indexGraphVerticesMap()
orIntGraph.indexGraphEdgesMap()
.- Parameters:
id
- an ID of an element (vertex/edge)- Returns:
- the index of the element
- Throws:
NoSuchVertexException
- if this map maps vertices to ids andid
is not a valid identifier of a vertexNoSuchEdgeException
- if this map maps edges to ids andid
is not a valid identifier of an edge
-
idToIndex
@Deprecated default int idToIndex(Integer id)
Deprecated.Please useidToIndex(int)
instead to avoid un/boxing.Get the index of an element by its identifier.Whether this method maps vertices or edges depends if the mapping object was obtained by
Graph.indexGraphVerticesMap()
orGraph.indexGraphEdgesMap()
.- Specified by:
idToIndex
in interfaceIndexIdMap<Integer>
- Parameters:
id
- an identifier of an element (vertex/edge)- Returns:
- the index of the element
-
idToIndexIfExist
int idToIndexIfExist(int id)
Get the index of an element by its identifier if it exists, or-1
if it doesn't.Whether this method maps vertices or edges depends if the mapping object was obtained by
Graph.indexGraphVerticesMap()
orGraph.indexGraphEdgesMap()
.- Parameters:
id
- an identifier of an element (vertex/edge)- Returns:
- the index of the element, or
-1
if there is not such element
-
idToIndexIfExist
@Deprecated default int idToIndexIfExist(Integer id)
Deprecated.Please useidToIndexIfExist(int)
instead to avoid un/boxing.Get the index of an element by its identifier if it exists, or-1
if it doesn't.Whether this method maps vertices or edges depends if the mapping object was obtained by
Graph.indexGraphVerticesMap()
orGraph.indexGraphEdgesMap()
.- Specified by:
idToIndexIfExist
in interfaceIndexIdMap<Integer>
- Parameters:
id
- an identifier of an element (vertex/edge)- Returns:
- the index of the element, or
-1
if there is not such element
-
identityVerticesMap
static IndexIntIdMap identityVerticesMap(IntSet vertexSet)
Create an identity mapping between the elements IDs and indices.The identity mapping is a mapping in which the ID of an element is equal to its index. This mapping is used by index graphs. The passed set of vertices is expected to be
0,1,2, ..., n-1
wheren
is the number of vertices in the graph, as only for this set of vertices the identity mapping is possible. The given set is not validated for this condition. The number of vertices,n
, is accessible to the mapping byvertexSet.size()
, and it is used to determine if an index/id is in range. If the graph is mutable and the mapping should be used during the graph lifetime, the given set should be a view of the graph vertices, so the range checks will be valid.- Parameters:
vertexSet
- the set of vertices in the graph. The set will be used t- Returns:
- an identity mapping of the vertices
-
identityEdgesMap
static IndexIntIdMap identityEdgesMap(IntSet edgeSet)
Create an identity mapping between the elements IDs and indices.The identity mapping is a mapping in which the ID of an element is equal to its index. This mapping is used by index graphs. The passed set of edges is expected to be
0,1,2, ..., m-1
wherem
is the number of edges in the graph, as only for this set of edges the identity mapping is possible. The given set is not validated for this condition. The number of edges,m
, is accessible to the mapping byedgeSet.size()
, and it is used to determine if an index/id is in range. If the graph is mutable and the mapping should be used during the graph lifetime, the given set should be a view of the graph edges, so the range checks will be valid.- Parameters:
edgeSet
- the set of edges in the graph. The set will be used t- Returns:
- an identity mapping of the edges
-
-