Module org.jhotdraw8.graph
Package org.jhotdraw8.graph.path.algo
Class UniqueOrOneHopVertexPathSearchAlgo<V,C extends Number & Comparable<C>>
java.lang.Object
org.jhotdraw8.graph.path.algo.UniqueOrOneHopVertexPathSearchAlgo<V,C>
- Type Parameters:
V- the vertex data typeC- the cost number type
- All Implemented Interfaces:
VertexPathSearchAlgo<V,C>
public class UniqueOrOneHopVertexPathSearchAlgo<V,C extends Number & Comparable<C>>
extends Object
implements VertexPathSearchAlgo<V,C>
Builder for creating unique paths from a directed graph.
The builder searches for unique paths using a breadth-first search.
Returns only a path if it is unique or if there is only one hop
from start to goal.
- Author:
- Werner Randelshofer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionsearch(@NonNull Iterable<V> startVertices, @NonNull Predicate<V> goalPredicate, @NonNull Function<V, Iterable<V>> nextVerticesFunction, int maxDepth, @NonNull C zero, @NonNull C costLimit, @NonNull BiFunction<V, V, C> costFunction, @NonNull BiFunction<C, C, C> sumFunction, @NonNull AddToSet<V> visited) Search engine method.search(@NonNull Iterable<V> startVertices, @NonNull Predicate<V> goalPredicate, @NonNull Function<V, Iterable<V>> nextVerticesFunction, @NonNull AddToSet<V> visited, int maxDepth, @NonNull C zero, @NonNull BiFunction<V, V, C> costFunction, @NonNull BiFunction<C, C, C> sumFunction) Search engine method.
-
Constructor Details
-
UniqueOrOneHopVertexPathSearchAlgo
public UniqueOrOneHopVertexPathSearchAlgo()
-
-
Method Details
-
search
public @Nullable VertexBackLinkWithCost<V,C> search(@NonNull Iterable<V> startVertices, @NonNull Predicate<V> goalPredicate, @NonNull Function<V, Iterable<V>> nextVerticesFunction, int maxDepth, @NonNull C zero, @NonNull C costLimit, @NonNull BiFunction<V, V, C> costFunction, @NonNull BiFunction<C, C, C> sumFunction, @NonNull AddToSet<V> visited) Description copied from interface:VertexPathSearchAlgoSearch engine method.- Specified by:
searchin interfaceVertexPathSearchAlgo<V,C extends Number & Comparable<C>> - Parameters:
startVertices- the set of start verticesgoalPredicate- the goal predicatenextVerticesFunction- the next vertices functionmaxDepth- the maximal depth (inclusive) of the search Must be >= 0.zero- the zero cost valuecostLimit- the algorithm-specific cost limitsumFunction- the sum function for adding two cost valuesvisited- the visited function- Returns:
- on success: a back link, otherwise: null
-
search
public @Nullable VertexBackLinkWithCost<V,C> search(@NonNull Iterable<V> startVertices, @NonNull Predicate<V> goalPredicate, @NonNull Function<V, Iterable<V>> nextVerticesFunction, @NonNull AddToSet<V> visited, int maxDepth, @NonNull C zero, @NonNull BiFunction<V, V, C> costFunction, @NonNull BiFunction<C, C, C> sumFunction) Search engine method.- Parameters:
startVertices- the set of start verticesgoalPredicate- the goal predicatenextVerticesFunction- the next arcs functionvisited- the set of visited vertices (seeAddToSet)zero- the zero cost valuecostFunction- the cost functionsumFunction- the sum function for adding two cost values- Returns:
- on success: a back link, otherwise: null
-