java.lang.Object
org.jgrapht.alg.shortestpath.DijkstraSpurEngine<V,E>
- Type Parameters:
V- graph vertex typeE- graph edge type
- All Implemented Interfaces:
SpurShortestPathEngine<V,E>
Spur shortest-path engine that delegates to JGraphT's
DijkstraShortestPath. Bans are
applied by wrapping the input graph in a MaskSubgraph so we do not duplicate or modify
the underlying Dijkstra implementation. The reverseDistancesToSink hint is unused
here; it is consumed by the bounded-pruned Yen driver itself, not by this engine.
Edge weights must be non-negative (a Dijkstra precondition).
The expandedVertices() counter is reported as 0 because
DijkstraShortestPath does not expose a per-call expansion count. The metric is
documented as best-effort on SpurShortestPathEngine.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongNumber of vertices the engine has expanded (popped from its open set) since the lastSpurShortestPathEngine.resetCounters()call.findPath(Graph<V, E> graph, V source, V sink, Set<V> bannedVertices, Set<E> bannedEdges, Map<V, Double> reverseDistancesToSink) Compute an exact shortest path fromsourcetosinkongraphignoring vertices inbannedVerticesand edges inbannedEdges.name()Symbolic name of the engine, used in benchmark reports.longNumber of shortest-path queries answered since the lastSpurShortestPathEngine.resetCounters()call.voidReset internal counters.
-
Constructor Details
-
DijkstraSpurEngine
public DijkstraSpurEngine()
-
-
Method Details
-
findPath
public GraphPath<V,E> findPath(Graph<V, E> graph, V source, V sink, Set<V> bannedVertices, Set<E> bannedEdges, Map<V, Double> reverseDistancesToSink) Description copied from interface:SpurShortestPathEngineCompute an exact shortest path fromsourcetosinkongraphignoring vertices inbannedVerticesand edges inbannedEdges.- Specified by:
findPathin interfaceSpurShortestPathEngine<V,E> - Parameters:
graph- original graph (engines should not mutate it)source- source vertex of the spur querysink- target vertex of the spur querybannedVertices- vertices to ignore (must not includesourceorsink)bannedEdges- edges to ignorereverseDistancesToSink- optional hint, lower-bound distances from each vertex tosinkcomputed on the original graph; may benullfor engines that do not need it- Returns:
- the shortest path or
nullif no path exists in the masked graph
-
expandedVertices
public long expandedVertices()Description copied from interface:SpurShortestPathEngineNumber of vertices the engine has expanded (popped from its open set) since the lastSpurShortestPathEngine.resetCounters()call. Best-effort metric used by benchmarks; engines that do not track expansion (e.g. those delegating to a back-end without a public expansion counter) may return0.- Specified by:
expandedVerticesin interfaceSpurShortestPathEngine<V,E> - Returns:
- number of vertices popped from the engine's open set since the last reset, or
0when not tracked
-
pathQueries
public long pathQueries()Description copied from interface:SpurShortestPathEngineNumber of shortest-path queries answered since the lastSpurShortestPathEngine.resetCounters()call.- Specified by:
pathQueriesin interfaceSpurShortestPathEngine<V,E> - Returns:
- number of shortest-path queries answered since the last reset
-
resetCounters
public void resetCounters()Description copied from interface:SpurShortestPathEngineReset internal counters. Called byBoundedPrunedYenKShortestPathbetween independent runs so that counters report per-run statistics.- Specified by:
resetCountersin interfaceSpurShortestPathEngine<V,E>
-
name
Description copied from interface:SpurShortestPathEngineSymbolic name of the engine, used in benchmark reports.- Specified by:
namein interfaceSpurShortestPathEngine<V,E> - Returns:
- a short human-readable identifier for this engine
-