Interface IndexIdMap
-
public interface IndexIdMapA mapping betweenGraphIDs toIndexGraphindices.A regular graph contains vertices and edges which are identified by a fixed
intIDs. AnIndexGraphview 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
Graph.indexGraphVerticesMap()it will map between vertices IDs and indices, and if it was obtained byGraph.indexGraphEdgesMap()it will map between edges IDs and indices.- Author:
- Barak Ugav
- See Also:
IndexGraph
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intidToIndex(int id)Get the index of an element by its ID.intindexToId(int index)Get the ID of an element by its index.
-
-
-
Method Detail
-
indexToId
int indexToId(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
Graph.indexGraphVerticesMap()orGraph.indexGraphEdgesMap().- Parameters:
index- an index of an element (vertex/edge)- Returns:
- the ID of the element
- Throws:
IndexOutOfBoundsException- ifindexis not in range[, elementsNum)whereelementsNumis the number of either vertices or edges, depending on the context
-
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
Graph.indexGraphVerticesMap()orGraph.indexGraphEdgesMap().- Parameters:
id- an ID of an element (vertex/edge)- Returns:
- the index of the element
- Throws:
IndexOutOfBoundsException- ifidis not a valid identifier of vertex/edge, depending on the context
-
-