java.lang.Object
org.jgrapht.graph.DirectedAcyclicGraph.TopoVertexMap
- All Implemented Interfaces:
Serializable
,DirectedAcyclicGraph.TopoOrderMap<V>
- Enclosing class:
DirectedAcyclicGraph<V,
E>
protected class DirectedAcyclicGraph.TopoVertexMap
extends 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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetTopologicalIndex
(V vertex) Get the topological index of the given vertex.Get the vertex at the given topological index.void
Add a vertex at the given topological index.void
Remove all vertices from the topological ordering.removeVertex
(V vertex) Remove the given vertex from the topological ordering.private int
translateIndex
(int index) We translate the topological index to an ArrayList index.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
topoToVertex
-
vertexToTopo
-
-
Constructor Details
-
TopoVertexMap
public TopoVertexMap()Constructor
-
-
Method Details
-
putVertex
Description copied from interface:DirectedAcyclicGraph.TopoOrderMap
Add a vertex at the given topological index.- Specified by:
putVertex
in interfaceDirectedAcyclicGraph.TopoOrderMap<V>
- Parameters:
index
- the topological indexvertex
- the vertex
-
getVertex
Description copied from interface:DirectedAcyclicGraph.TopoOrderMap
Get the vertex at the given topological index.- Specified by:
getVertex
in interfaceDirectedAcyclicGraph.TopoOrderMap<V>
- Parameters:
index
- the topological index- Returns:
- vertex the vertex
-
getTopologicalIndex
Description copied from interface:DirectedAcyclicGraph.TopoOrderMap
Get the topological index of the given vertex.- Specified by:
getTopologicalIndex
in 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
Description copied from interface:DirectedAcyclicGraph.TopoOrderMap
Remove the given vertex from the topological ordering.- Specified by:
removeVertex
in 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.TopoOrderMap
Remove all vertices from the topological ordering.- Specified by:
removeAllVertices
in 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
-