- java.lang.Object
-
- org.jgrapht.graph.DirectedAcyclicGraph.TopoVertexMap
-
- All Implemented Interfaces:
java.io.Serializable,DirectedAcyclicGraph.TopoOrderMap<V>
- Enclosing class:
- DirectedAcyclicGraph<V,E>
protected class DirectedAcyclicGraph.TopoVertexMap extends java.lang.Object implements DirectedAcyclicGraph.TopoOrderMap<V>
An implementation of the topological order map which for performance and flexibility uses an ArrayList for topological index to vertex mapping, and a HashMap for vertex to topological index mapping.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static longserialVersionUIDprivate java.util.List<V>topoToVertexprivate java.util.Map<V,java.lang.Integer>vertexToTopo
-
Constructor Summary
Constructors Constructor Description TopoVertexMap()Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.IntegergetTopologicalIndex(V vertex)Get the topological index of the given vertex.VgetVertex(java.lang.Integer index)Get the vertex at the given topological index.voidputVertex(java.lang.Integer index, V vertex)Add a vertex at the given topological index.voidremoveAllVertices()Remove all vertices from the topological ordering.java.lang.IntegerremoveVertex(V vertex)Remove the given vertex from the topological ordering.private inttranslateIndex(int index)We translate the topological index to an ArrayList index.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
topoToVertex
private final java.util.List<V> topoToVertex
-
vertexToTopo
private final java.util.Map<V,java.lang.Integer> vertexToTopo
-
-
Method Detail
-
putVertex
public void putVertex(java.lang.Integer index, V vertex)Description copied from interface:DirectedAcyclicGraph.TopoOrderMapAdd a vertex at the given topological index.- Specified by:
putVertexin interfaceDirectedAcyclicGraph.TopoOrderMap<V>- Parameters:
index- the topological indexvertex- the vertex
-
getVertex
public V getVertex(java.lang.Integer index)
Description copied from interface:DirectedAcyclicGraph.TopoOrderMapGet the vertex at the given topological index.- Specified by:
getVertexin interfaceDirectedAcyclicGraph.TopoOrderMap<V>- Parameters:
index- the topological index- Returns:
- vertex the vertex
-
getTopologicalIndex
public java.lang.Integer getTopologicalIndex(V vertex)
Description copied from interface:DirectedAcyclicGraph.TopoOrderMapGet the topological index of the given vertex.- Specified by:
getTopologicalIndexin interfaceDirectedAcyclicGraph.TopoOrderMap<V>- Parameters:
vertex- the vertex- Returns:
- the index that the vertex is at, or null if the vertex isn't in the topological ordering
-
removeVertex
public java.lang.Integer removeVertex(V vertex)
Description copied from interface:DirectedAcyclicGraph.TopoOrderMapRemove the given vertex from the topological ordering.- Specified by:
removeVertexin interfaceDirectedAcyclicGraph.TopoOrderMap<V>- Parameters:
vertex- the vertex- Returns:
- the index that the vertex was at, or null if the vertex wasn't in the topological ordering
-
removeAllVertices
public void removeAllVertices()
Description copied from interface:DirectedAcyclicGraph.TopoOrderMapRemove all vertices from the topological ordering.- Specified by:
removeAllVerticesin interfaceDirectedAcyclicGraph.TopoOrderMap<V>
-
translateIndex
private int translateIndex(int index)
We translate the topological index to an ArrayList index. We have to do this because topological indices can be negative, and we want to do it because we can make better use of space by only needing an ArrayList of size |AR|.- Returns:
- the ArrayList index
-
-