public class Graph
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
Graph.PathsComparator
Comparator for sorting (shortest) paths.
|
class |
Graph.ReachedVerticesComparator
Comparator ordering vertices using pathCost function.
|
Modifier and Type | Field and Description |
---|---|
Graph.PathsComparator |
pathsComparator
Automatically created comparator for paths in this multigraph.
|
static int |
STRATUM_ZERO
Distinguished constant for the stratum zero.
|
Constructor and Description |
---|
Graph(java.util.Set<java.lang.String> targetStates,
int strataNumber)
Creates a new and empty instance of the correction multigraph.
|
Modifier and Type | Method and Description |
---|---|
void |
addNewEdge(Edge newEdge)
Adds a new edge into the multigraph.
|
void |
addNewVertex(Vertex newVertex)
Adds a new vertex into the multigraph.
|
void |
addTracingEdge(Vertex graphVertex,
Edge precedingEdge)
Adds a new preceding edge into the set of a given base vertex.
|
void |
clearTracingEdges(Vertex graphVertex)
Clears the existing set of preceding edges.
|
java.util.List<java.util.List<Edge>> |
fetchShortestPaths()
Generates the set of all shortest paths in the aggregated multigraph.
|
protected void |
generateShortestPaths(java.util.List<java.util.List<Edge>> outputSet,
Vertex targetVertex)
Generates all shortest paths ending in the specified target vertex.
|
Graph.ReachedVerticesComparator |
getComparatorReached()
Returns the reference to the initialized vertices comparator.
|
int |
getEdgesCount()
Returns the overall count of edges in the multigraph.
|
java.util.Set<Edge> |
getGraphEdges()
Returns the set of all edges in the multigraph.
|
java.util.Set<Vertex> |
getGraphVertices()
Returns the set of all vertices in the multigraph.
|
java.util.Set<Edge> |
getIngoingEdges(Vertex baseVertex)
Returns the set of all edges ingoing to the specified vertex.
|
java.util.Set<Edge> |
getOutgoingEdges(Vertex baseVertex)
Returns the set of all edges outgoing from the specified vertex.
|
java.lang.Integer |
getResolvedCost(Edge inspectedEdge)
Returns the computed cost to the target vertex using this edge only.
|
protected java.util.Set<java.lang.String> |
getTargetStates()
Returns the target states of the graph.
|
Vertex |
getTargetVertex(java.lang.String automatonState)
Attempts to fetch the existing vertex from the last stratum.
|
int |
getTermCost()
Returns the terminating cost of the aggregated multigraph.
|
java.lang.Integer |
getTracedCost(Edge inspectedEdge)
Returns the stored tracing cost for the target vertex of the edge.
|
java.lang.Integer |
getTracingCost(Vertex graphVertex)
Returns the cost of shortest paths leading to the given vertex.
|
java.util.Set<Edge> |
getTracingEdges(Vertex graphVertex)
Returns the set of preceding edges on shortest paths.
|
Vertex |
getVertexItem(java.lang.Integer stratumNumber,
java.lang.String automatonState)
Attempts to fetch the existing vertex from the multigraph.
|
int |
getVerticesCount()
Returns the overall count of vertices in the multigraph.
|
boolean |
hasVertexItem(Vertex inspectedVertex)
Detects whether the given vertex is already in the multigraph.
|
void |
initTracingEdges(Vertex graphVertex)
Creates a new empty set of preceding edges and replaces the original.
|
void |
printDebugDump(java.lang.String indentPrefix)
Prints the debugging dump of the repairing multigraph.
|
void |
removeTracingEdges(Vertex graphVertex)
Completely removes the set of preceding edges.
|
void |
setTermCost(int newCost)
Updates the value of the terminating cost.
|
void |
setTracingCost(Vertex graphVertex,
java.lang.Integer newCost)
Sets a new path cost value for a given vertex.
|
void |
setTracingEdges(Vertex graphVertex,
java.util.Set<Edge> prevEdges)
Sets the new set of preceding edges on shortest paths.
|
public static int STRATUM_ZERO
public final Graph.PathsComparator pathsComparator
public Graph(java.util.Set<java.lang.String> targetStates, int strataNumber)
targetStates
- Set of all target states.strataNumber
- Total number of strata.public java.util.Set<Vertex> getGraphVertices()
public java.util.Set<Edge> getGraphEdges()
public int getVerticesCount()
public int getEdgesCount()
public void addNewVertex(Vertex newVertex)
newVertex
- New vertex to be inserted.public Vertex getVertexItem(java.lang.Integer stratumNumber, java.lang.String automatonState)
stratumNumber
- Specified stratum number.automatonState
- Specified automaton state name.null
.public boolean hasVertexItem(Vertex inspectedVertex)
inspectedVertex
- Specified stratum number and automaton state.true
if the given vertex already exists.public Vertex getTargetVertex(java.lang.String automatonState)
automatonState
- Specified automaton state name.null
.public void addNewEdge(Edge newEdge)
newEdge
- New edge to be inserted.public java.util.Set<Edge> getIngoingEdges(Vertex baseVertex)
baseVertex
- Specifies base vertex.null
.public java.util.Set<Edge> getOutgoingEdges(Vertex baseVertex)
baseVertex
- Specifies base vertex.null
.protected java.util.Set<java.lang.String> getTargetStates()
public java.util.Set<Edge> getTracingEdges(Vertex graphVertex)
graphVertex
- Specified base vertex.null
.public void setTracingEdges(Vertex graphVertex, java.util.Set<Edge> prevEdges)
graphVertex
- Specified base vertex.prevEdges
- Reference to the new set of preceding edges.public void removeTracingEdges(Vertex graphVertex)
graphVertex
- Specified base vertex.public void clearTracingEdges(Vertex graphVertex)
graphVertex
- Specified base vertex.public void initTracingEdges(Vertex graphVertex)
graphVertex
- Specified base vertex.public void addTracingEdge(Vertex graphVertex, Edge precedingEdge)
graphVertex
- Specified base vertex.precedingEdge
- Preceding edge to be added.public java.lang.Integer getTracingCost(Vertex graphVertex)
null
is returned.graphVertex
- Specified base vertex.public void setTracingCost(Vertex graphVertex, java.lang.Integer newCost)
graphVertex
- Specified base vertex.newCost
- New value of the pathCost function.public java.lang.Integer getTracedCost(Edge inspectedEdge)
inspectedEdge
- Reference to the edge to be inspected.null
.public java.lang.Integer getResolvedCost(Edge inspectedEdge)
inspectedEdge
- Reference to the edge to be inspected.null
.public int getTermCost()
public void setTermCost(int newCost)
newCost
- New value of termCost function.protected void generateShortestPaths(java.util.List<java.util.List<Edge>> outputSet, Vertex targetVertex)
outputSet
- Prepared output container for found paths.targetVertex
- Target vertex of specified paths.public java.util.List<java.util.List<Edge>> fetchShortestPaths()
public Graph.ReachedVerticesComparator getComparatorReached()
public void printDebugDump(java.lang.String indentPrefix)
indentPrefix
- Indentation string.