Module org.jhotdraw8.graph
Package org.jhotdraw8.graph.path
Class SimpleVertexSequenceFinder<V,C extends Number & Comparable<C>>
java.lang.Object
org.jhotdraw8.graph.path.SimpleVertexSequenceFinder<V,C>
- Type Parameters:
V- the vertex data typeC- the cost number type
- All Implemented Interfaces:
VertexSequenceFinder<V,C>
public class SimpleVertexSequenceFinder<V,C extends Number & Comparable<C>>
extends Object
implements VertexSequenceFinder<V,C>
Implements the
VertexSequenceFinder interface.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindVertexSequence(@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> @NonNull SimpleVertexSequenceFinder<VV, Integer> newIntCostInstance(@NonNull Function<VV, Iterable<VV>> nextVerticesFunction, @NonNull BiFunction<VV, VV, Integer> costFunction, @NonNull VertexPathSearchAlgo<VV, Integer> algo) Creates a new instance which has a cost function that returns integer numbers.static <VV> @NonNull SimpleVertexSequenceFinder<VV, Integer> newIntCostInstance(@NonNull Function<VV, Iterable<VV>> nextVerticesFunction, @NonNull VertexPathSearchAlgo<VV, Integer> algo) Creates a new instance which has a int cost function that counts the number of arrows.static <VV> @NonNull SimpleVertexSequenceFinder<VV, Long> newLongCostInstance(@NonNull Function<VV, Iterable<VV>> nextVerticesFunction, @NonNull BiFunction<VV, VV, Long> costFunction, @NonNull VertexPathSearchAlgo<VV, Long> algo) Creates a new instance which has 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.VertexSequenceFinder
findVertexSequence, findVertexSequence, findVertexSequence, findVertexSequence, findVertexSequence, findVertexSequence, findVertexSequence, findVertexSequence, findVertexSequenceOverWaypoints, findVertexSequenceOverWaypoints
-
Constructor Details
-
SimpleVertexSequenceFinder
public SimpleVertexSequenceFinder(@NonNull C zero, @NonNull Function<V, Iterable<V>> nextVerticesFunction, @NonNull BiFunction<V, V, C> costFunction, @NonNull BiFunction<C, C, C> sumFunction, @NonNull VertexPathSearchAlgo<V, C> algo) Creates a new instance.- Parameters:
zero- the zero value, e.g.0,0.0.nextVerticesFunction- a function that given a vertex, returns anIterablefor the next vertices of 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> @NonNull SimpleVertexSequenceFinder<VV,Integer> newIntCostInstance(@NonNull Function<VV, Iterable<VV>> nextVerticesFunction, @NonNull BiFunction<VV, VV, Integer> costFunction, @NonNull VertexPathSearchAlgo<VV, Integer> algo) Creates a new instance which has a cost function that returns integer numbers.- Type Parameters:
VV- the vertex data type- Parameters:
nextVerticesFunction- a function that given a vertex, returns anIterablefor the next vertices of that vertex.costFunction- the cost functionalgo- the search algorithm- Returns:
- the new
SimpleVertexSequenceFinderinstance.
-
newIntCostInstance
public static <VV> @NonNull SimpleVertexSequenceFinder<VV,Integer> newIntCostInstance(@NonNull Function<VV, Iterable<VV>> nextVerticesFunction, @NonNull VertexPathSearchAlgo<VV, Integer> algo) Creates a new instance which has a int cost function that counts the number of arrows.- Type Parameters:
VV- the vertex data type- Parameters:
nextVerticesFunction- a function that given a vertex, returns anIterablefor the next vertices of that vertex.algo- the search algorithm- Returns:
- the new
SimpleVertexSequenceFinderinstance.
-
newLongCostInstance
public static <VV> @NonNull SimpleVertexSequenceFinder<VV,Long> newLongCostInstance(@NonNull Function<VV, Iterable<VV>> nextVerticesFunction, @NonNull BiFunction<VV, VV, Long> costFunction, @NonNull VertexPathSearchAlgo<VV, Long> algo) Creates a new instance which has a cost function that returns long numbers.- Type Parameters:
VV- the vertex data type- Parameters:
nextVerticesFunction- a function that given a vertex, returns anIterablefor the next vertices of that vertex.costFunction- the cost functionalgo- the search algorithm- Returns:
- the new
SimpleVertexSequenceFinderinstance.
-
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,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 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,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 (vertex sequence, cost), or null if no sequence was found.
-