Module org.jhotdraw8.graph
Package org.jhotdraw8.graph.path.algo
Class UniqueArcPathSearchAlgo<V,A,C extends Number & Comparable<C>>
java.lang.Object
org.jhotdraw8.graph.path.algo.UniqueArcPathSearchAlgo<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 UniqueArcPathSearchAlgo<V,A,C extends Number & Comparable<C>>
extends Object
implements ArcPathSearchAlgo<V,A,C>
Searches a globally unique vertex path from a set of start vertices to a
set of goal vertices using a breadth-first search algorithm on a directed
(potentially cyclic) graph (DIG).
Uniqueness is global up to (inclusive) the specified maximal depth.
This algorithm ignores cost limit. If you need it, use one of the shortest path search algorithms.
Performance characteristics:
- When the algorithm returns a back link
- exactly O( |A| + |V| ) within max depth
- When the algorithm returns null
- less or equal O( |A| + |V| ) within max depth
References:
- Robert Sedgewick, Kevin Wayne. (2011)
- Algorithms, 4th Edition. Chapter 4. Breadth-First Search. math.cmu.edu
- 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) Search engine method.search(@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
-
UniqueArcPathSearchAlgo
public UniqueArcPathSearchAlgo()
-
-
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 cost limit is ignoredcostFunction- the cost functionsumFunction- the sum function for adding two cost valuesvisited-- Returns:
-
search
public @Nullable ArcBackLinkWithAncestorSet<V,A> search(@NonNull Iterable<V> startVertices, @NonNull Predicate<V> goalPredicate, @NonNull Function<V, Iterable<Arc<V, A>>> nextArcsFunction, int maxDepth) Search engine method.- Parameters:
startVertices- the set of start verticesgoalPredicate- the goal predicatenextArcsFunction- the next arcs functionmaxDepth- the maximal depth (inclusive) of the search Must be >= 0.- Returns:
- on success: a back link, otherwise: null
-