Module org.jhotdraw8.graph
Package org.jhotdraw8.graph.path
Class SimpleCombinedSequenceFinder<V,A,C extends Number & Comparable<C>>
java.lang.Object
org.jhotdraw8.graph.path.SimpleCombinedSequenceFinder<V,A,C>
- Type Parameters:
V- the vertex data typeA- the arrow data typeC- the cost number type
- All Implemented Interfaces:
ArcSequenceFinder<V,,A, C> ArrowSequenceFinder<V,,A, C> CombinedSequenceFinder<V,,A, C> VertexSequenceFinder<V,C>
public class SimpleCombinedSequenceFinder<V,A,C extends Number & Comparable<C>>
extends Object
implements CombinedSequenceFinder<V,A,C>
Implements the
CombinedSequenceFinder interface.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindArcSequence(@NonNull Iterable<V> startVertices, @NonNull Predicate<V> goalPredicate, int maxDepth, @NonNull C costLimit, @NonNull AddToSet<V> visited) Finds an arc sequence from a set of start vertices to a vertex that satisfies the goal predicate.findArcSequenceOverWaypoints(@NonNull Iterable<V> waypoints, int maxDepth, @NonNull C costLimit, @NonNull Supplier<AddToSet<V>> visitedSetFactory) Finds an arc sequence through the given waypoints.findArrowSequence(@NonNull Iterable<V> startVertices, @NonNull Predicate<V> goalPredicate, int maxDepth, @NonNull C costLimit, @NonNull AddToSet<V> visited) Finds an arrow sequence from a set of start vertices to a vertex that satisfies the goal predicate.findArrowSequenceOverWaypoints(@NonNull Iterable<V> waypoints, int maxDepth, @NonNull C costLimit, @NonNull Supplier<AddToSet<V>> visitedSetFactory) Finds an arrow sequence through the given waypoints.findVertexSequence(@NonNull Iterable<V> startVertices, @NonNull Predicate<V> goalPredicate, int maxDepth, @NonNull C costLimit, @NonNull AddToSet<V> visited) Finds a vertex sequence from a set of start vertices to a vertex that satisfies the goal predicate.findVertexSequenceOverWaypoints(@NonNull Iterable<V> waypoints, int maxDepth, @NonNull C costLimit, @NonNull Supplier<AddToSet<V>> visitedSetFactory) Finds a vertex sequence through the given waypoints.static <VV,AA> @NonNull SimpleCombinedSequenceFinder <VV, AA, Double> newDoubleCostInstance(@NonNull Function<VV, Iterable<Arc<VV, AA>>> nextArcsFunction, @NonNull Function3<VV, VV, AA, Double> costFunction, @NonNull ArcPathSearchAlgo<VV, AA, Double> algo) Creates a new instance with a cost function that returns double numbers.static <VV,AA> @NonNull SimpleCombinedSequenceFinder <VV, AA, Integer> newIntCostInstance(@NonNull Function<VV, Iterable<Arc<VV, AA>>> nextArcsFunction, @NonNull BiFunction<VV, VV, Integer> costFunction, @NonNull ArcPathSearchAlgo<VV, AA, Integer> algo) Creates a new instance with a cost function that returns integer numbers.static <VV,AA> @NonNull SimpleCombinedSequenceFinder <VV, AA, Integer> newIntCostInstance(@NonNull Function<VV, Iterable<Arc<VV, AA>>> nextArcsFunction, @NonNull Function3<VV, VV, AA, Integer> costFunction, @NonNull ArcPathSearchAlgo<VV, AA, Integer> algo) Creates a new instance with a cost function that returns integer numbers.static <VV,AA> @NonNull SimpleCombinedSequenceFinder <VV, AA, Integer> newIntCostInstance(@NonNull Function<VV, Iterable<Arc<VV, AA>>> nextArcsFunction, @NonNull ArcPathSearchAlgo<VV, AA, Integer> algo) Creates a new instance with a cost function that counts the number of arrows.static <VV,AA> @NonNull SimpleCombinedSequenceFinder <VV, AA, Long> newLongCostInstance(@NonNull Function<VV, Iterable<Arc<VV, AA>>> nextArcsFunction, @NonNull Function3<VV, VV, AA, Long> costFunction, @NonNull ArcPathSearchAlgo<VV, AA, Long> algo) Creates a new instance with a cost function that returns long numbers.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jhotdraw8.graph.path.ArcSequenceFinder
findArcSequence, findArcSequence, findArcSequence, findArcSequenceOverWaypoints, findArcSequenceOverWaypointsMethods inherited from interface org.jhotdraw8.graph.path.ArrowSequenceFinder
findArrowSequence, findArrowSequence, findArrowSequence, findArrowSequence, findArrowSequence, findArrowSequenceOverWaypoints, findArrowSequenceOverWaypointsMethods inherited from interface org.jhotdraw8.graph.path.VertexSequenceFinder
findVertexSequence, findVertexSequence, findVertexSequence, findVertexSequence, findVertexSequence, findVertexSequence, findVertexSequence, findVertexSequence, findVertexSequenceOverWaypoints, findVertexSequenceOverWaypoints
-
Constructor Details
-
SimpleCombinedSequenceFinder
public SimpleCombinedSequenceFinder(@NonNull C zero, @NonNull Function<V, Iterable<Arc<V, A>>> nextArcsFunction, @NonNull Function3<V, V, A, C> costFunction, @NonNull BiFunction<C, C, C> sumFunction, @NonNull ArcPathSearchAlgo<V, A, C> algo) Creates a new instance.- Parameters:
zero- the zero value, e.g.0,0.0.nextArcsFunction- a function that given a vertex, returns anIterablefor theArcs starting at that vertex.costFunction- the cost functionsumFunction- the sum function, which adds two numbers, e.g.Integer.sum(int, int),Double.sum(double, double).algo- the search algorithm
-
-
Method Details
-
newIntCostInstance
public static <VV,AA> @NonNull SimpleCombinedSequenceFinder<VV,AA, newIntCostInstanceInteger> (@NonNull Function<VV, Iterable<Arc<VV, AA>>> nextArcsFunction, @NonNull Function3<VV, VV, AA, Integer> costFunction, @NonNull ArcPathSearchAlgo<VV, AA, Integer> algo) Creates a new instance with a cost function that returns integer numbers.- Type Parameters:
VV- the vertex data typeAA- the arrow data type- Parameters:
nextArcsFunction- a function that given a vertex, returns anIterablefor the next arcs of that vertex.costFunction- the cost functionalgo- the search algorithm- Returns:
- the new
SimpleCombinedSequenceFinderinstance.
-
newIntCostInstance
public static <VV,AA> @NonNull SimpleCombinedSequenceFinder<VV,AA, newIntCostInstanceInteger> (@NonNull Function<VV, Iterable<Arc<VV, AA>>> nextArcsFunction, @NonNull BiFunction<VV, VV, Integer> costFunction, @NonNull ArcPathSearchAlgo<VV, AA, Integer> algo) Creates a new instance with a cost function that returns integer numbers.- Type Parameters:
VV- the vertex data typeAA- the arrow data type- Parameters:
nextArcsFunction- a function that given a vertex, returns anIterablefor the next arcs of that vertex.costFunction- the cost functionalgo- the search algorithm- Returns:
- the new
SimpleCombinedSequenceFinderinstance.
-
newIntCostInstance
public static <VV,AA> @NonNull SimpleCombinedSequenceFinder<VV,AA, newIntCostInstanceInteger> (@NonNull Function<VV, Iterable<Arc<VV, AA>>> nextArcsFunction, @NonNull ArcPathSearchAlgo<VV, AA, Integer> algo) Creates a new instance with a cost function that counts the number of arrows.- Type Parameters:
VV- the vertex data typeAA- the arrow data type- Parameters:
nextArcsFunction- a function that given a vertex, returns anIterablefor the next arcs of that vertex.algo- the search algorithm- Returns:
- the new
SimpleCombinedSequenceFinderinstance.
-
newDoubleCostInstance
public static <VV,AA> @NonNull SimpleCombinedSequenceFinder<VV,AA, newDoubleCostInstanceDouble> (@NonNull Function<VV, Iterable<Arc<VV, AA>>> nextArcsFunction, @NonNull Function3<VV, VV, AA, Double> costFunction, @NonNull ArcPathSearchAlgo<VV, AA, Double> algo) Creates a new instance with a cost function that returns double numbers.- Type Parameters:
VV- the vertex data typeAA- the arrow data type- Parameters:
nextArcsFunction- a function that given a vertex, returns anIterablefor the next arcs of that vertex.costFunction- the cost functionalgo- the search algorithm- Returns:
- the new
SimpleCombinedSequenceFinderinstance.
-
newLongCostInstance
public static <VV,AA> @NonNull SimpleCombinedSequenceFinder<VV,AA, newLongCostInstanceLong> (@NonNull Function<VV, Iterable<Arc<VV, AA>>> nextArcsFunction, @NonNull Function3<VV, VV, AA, Long> costFunction, @NonNull ArcPathSearchAlgo<VV, AA, Long> algo) Creates a new instance with a cost function that returns long numbers.- Type Parameters:
VV- the vertex data typeAA- the arrow data type- Parameters:
nextArcsFunction- a function that given a vertex, returns anIterablefor the next arcs of that vertex.costFunction- the cost functionalgo- the search algorithm- Returns:
- the new
SimpleCombinedSequenceFinderinstance.
-
findArcSequence
public @Nullable OrderedPair<ImmutableList<Arc<V,A>>, findArcSequenceC> (@NonNull Iterable<V> startVertices, @NonNull Predicate<V> goalPredicate, int maxDepth, @NonNull C costLimit, @NonNull AddToSet<V> visited) Description copied from interface:ArcSequenceFinderFinds an arc sequence from a set of start vertices to a vertex that satisfies the goal predicate.- Specified by:
findArcSequencein interfaceArcSequenceFinder<V,A, C extends Number & Comparable<C>> - Parameters:
startVertices- the start verticesgoalPredicate- the goal vertexmaxDepth- the maximal depth (inclusive) of the search Must be >= 0.costLimit- the algorithm-specific search limitvisited- the visited function- Returns:
- an ordered pair (arc sequence, cost), or null if no sequence was found.
-
findArcSequenceOverWaypoints
public @Nullable OrderedPair<ImmutableList<Arc<V,A>>, findArcSequenceOverWaypointsC> (@NonNull Iterable<V> waypoints, int maxDepth, @NonNull C costLimit, @NonNull Supplier<AddToSet<V>> visitedSetFactory) Description copied from interface:ArcSequenceFinderFinds an arc sequence through the given waypoints.- Specified by:
findArcSequenceOverWaypointsin interfaceArcSequenceFinder<V,A, C extends Number & Comparable<C>> - Parameters:
waypoints- an iterable of waypointsmaxDepth- the maximal depth (inclusive) of the search Must be >= 0.costLimit- the algorithm-specific cost limit for paths between waypointsvisitedSetFactory- the visited set factory- Returns:
- an ordered pair (arc sequence, cost), or null if no sequence was found.
-
findArrowSequence
public @Nullable SimpleOrderedPair<ImmutableList<A>,C> findArrowSequence(@NonNull Iterable<V> startVertices, @NonNull Predicate<V> goalPredicate, int maxDepth, @NonNull C costLimit, @NonNull AddToSet<V> visited) Description copied from interface:ArrowSequenceFinderFinds an arrow sequence from a set of start vertices to a vertex that satisfies the goal predicate.- Specified by:
findArrowSequencein interfaceArrowSequenceFinder<V,A, C extends Number & Comparable<C>> - Parameters:
startVertices- the start vertexgoalPredicate- the goal predicatemaxDepth- the maximal depth (inclusive) of the search Must be >= 0.costLimit- the algorithm-specific cost limitvisited- the visited function- Returns:
- an ordered pair (arrow sequence, cost), or null if no sequence was found.
-
findArrowSequenceOverWaypoints
public @Nullable SimpleOrderedPair<ImmutableList<A>,C> findArrowSequenceOverWaypoints(@NonNull Iterable<V> waypoints, int maxDepth, @NonNull C costLimit, @NonNull Supplier<AddToSet<V>> visitedSetFactory) Description copied from interface:ArrowSequenceFinderFinds an arrow sequence through the given waypoints.- Specified by:
findArrowSequenceOverWaypointsin interfaceArrowSequenceFinder<V,A, C extends Number & Comparable<C>> - Parameters:
waypoints- a list of waypointsmaxDepth- the maximal depth (inclusive) of the search Must be >= 0.costLimit- the algorithm-specific cost limit for paths between waypointsvisitedSetFactory- the visited set factory- Returns:
- an ordered pair (arrow sequence, cost), or null if no sequence was found.
-
findVertexSequence
public @Nullable SimpleOrderedPair<ImmutableList<V>,C> findVertexSequence(@NonNull Iterable<V> startVertices, @NonNull Predicate<V> goalPredicate, int maxDepth, @NonNull C costLimit, @NonNull AddToSet<V> visited) Description copied from interface:VertexSequenceFinderFinds a vertex sequence from a set of start vertices to a vertex that satisfies the goal predicate.- Specified by:
findVertexSequencein interfaceVertexSequenceFinder<V,A> - Parameters:
startVertices- the start verticesgoalPredicate- the goal vertexmaxDepth- the maximal depth (inclusive) of the search Must be >= 0.costLimit- the algorithm-specific cost limitvisited- the visited set- Returns:
- an ordered pair (vertex sequence, cost), or null if no sequence was found.
-
findVertexSequenceOverWaypoints
public @Nullable SimpleOrderedPair<ImmutableList<V>,C> findVertexSequenceOverWaypoints(@NonNull Iterable<V> waypoints, int maxDepth, @NonNull C costLimit, @NonNull Supplier<AddToSet<V>> visitedSetFactory) Description copied from interface:VertexSequenceFinderFinds a vertex sequence through the given waypoints.- Specified by:
findVertexSequenceOverWaypointsin interfaceVertexSequenceFinder<V,A> - Parameters:
waypoints- a list of waypointsmaxDepth- the maximal depth (inclusive) of the search Must be >= 0.costLimit- the algorithm-specific cost limit for paths between waypointsvisitedSetFactory- the visited set factory- Returns:
- an ordered pair (vertex sequence, cost), or null if no sequence was found.
-