Module org.jhotdraw8.graph
Package org.jhotdraw8.graph.path.algo
Class UniqueShortestArcPathSearchAlgo<V,A,C extends Number & Comparable<C>>
java.lang.Object
org.jhotdraw8.graph.path.algo.UniqueShortestArcPathSearchAlgo<V,A,C>
- Type Parameters:
V- the vertex data typeA- the arrow data typeC- the cost number type
- All Implemented Interfaces:
ArcPathSearchAlgo<V,A, C>
public class UniqueShortestArcPathSearchAlgo<V,A,C extends Number & Comparable<C>>
extends Object
implements ArcPathSearchAlgo<V,A,C>
Searches a unique shortest path from a set of start vertices to a set of goal
vertices using Dijkstra's algorithm.
If the graph is acyclic, then the provided cost function must return values
>= 0 for all arrows.
If the graph has cycles, then the provided cost function must return values
> 0 for all arrows. (If the graph has cycles and the cost function
returns values that are 0, then this algorithm incorrectly considers a
path as non-unique, if it can be reached by a walk).
Performance characteristics:
- When the algorithm returns a back link
- less or equal O( |A| + |V|*log|V| ) within max cost
- When the algorithm returns null
- less or equal O( |A| + |V|*log|V| ) within max cost
References:
- Edsger W. Dijkstra (1959)
- A note on two problems in connexion with graphs,Problem 2. tum.de
- Sampath Kannan, Sanjeef Khanna, Sudeepa Roy. (2008)
- STCON in Directed Unique-Path Graphs. Chapter 2.1 Properties of Unique-Path Graphs. cis.upenn.edu
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionsearch(@NonNull Iterable<V> startVertices, @NonNull Predicate<V> goalPredicate, @NonNull Function<V, Iterable<Arc<V, A>>> nextArcsFunction, int maxDepth, @NonNull C zero, @NonNull C costLimit, @NonNull Function3<V, V, A, C> costFunction, @NonNull BiFunction<C, C, C> sumFunction, @NonNull AddToSet<V> visited) Search engine method.
-
Constructor Details
-
UniqueShortestArcPathSearchAlgo
public UniqueShortestArcPathSearchAlgo()
-
-
Method Details
-
search
public @Nullable ArcBackLinkWithCost<V,A, searchC> (@NonNull Iterable<V> startVertices, @NonNull Predicate<V> goalPredicate, @NonNull Function<V, Iterable<Arc<V, A>>> nextArcsFunction, int maxDepth, @NonNull C zero, @NonNull C costLimit, @NonNull Function3<V, V, A, C> costFunction, @NonNull BiFunction<C, C, C> sumFunction, @NonNull AddToSet<V> visited) Search engine method.- Specified by:
searchin interfaceArcPathSearchAlgo<V,A, C extends Number & Comparable<C>> - Parameters:
startVertices- the set of start verticesgoalPredicate- the goal predicatenextArcsFunction- the next arcs functionmaxDepth- the maximal depth (inclusive) of the search Must be >= 0.zero- the zero cost valuecostLimit- the maximal cost (inclusive) of a path. Must be >= zero.costFunction- the cost function.
The cost must be > 0 if the graph has cycles.
The cost must be >= 0 if the graph is acyclic.sumFunction- the sum function for adding two cost valuesvisited-- Returns:
- on success: a back link, otherwise: null
-