Module org.jhotdraw8.graph
Package org.jhotdraw8.graph.path
Class SimpleIndexedVertexSequenceFinder<C extends Number & Comparable<C>>
java.lang.Object
org.jhotdraw8.graph.path.SimpleIndexedVertexSequenceFinder<C>
- Type Parameters:
C- the cost number type
- All Implemented Interfaces:
VertexSequenceFinder<Integer,C>
public class SimpleIndexedVertexSequenceFinder<C extends Number & Comparable<C>>
extends Object
implements VertexSequenceFinder<Integer,C>
Implements the
VertexSequenceFinder interface.-
Constructor Summary
ConstructorsConstructorDescriptionSimpleIndexedVertexSequenceFinder(@NonNull C zero, @NonNull Function<Integer, Spliterator.OfInt> nextVerticesFunction, @NonNull BiFunction<Integer, Integer, C> costFunction, @NonNull BiFunction<C, C, C> sumFunction, @NonNull IndexedVertexPathSearchAlgo<C> algo) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionfindVertexSequence(@NonNull Iterable<Integer> startVertices, @NonNull Predicate<Integer> goalPredicate, int maxDepth, @NonNull C costLimit, @NonNull AddToSet<Integer> visited) Finds a vertex sequence from a set of start vertices to a vertex that satisfies the goal predicate.findVertexSequenceOverWaypoints(@NonNull Iterable<Integer> waypoints, int maxDepth, @NonNull C costLimit, @NonNull Supplier<AddToSet<Integer>> visitedSetFactory) Finds a vertex sequence through the given waypoints.newIntCostInstance(@NonNull Function<Integer, Spliterator.OfInt> nextVerticesFunction, @NonNull BiFunction<Integer, Integer, Integer> costFunction, @NonNull IndexedVertexPathSearchAlgo<Integer> algo) Creates a new instance which has a cost function that returns integer numbers.newIntCostInstance(@NonNull Function<Integer, Spliterator.OfInt> nextVerticesFunction, @NonNull IndexedVertexPathSearchAlgo<Integer> algo) Creates a new instance which has a int cost function that counts the number of arrows.newLongCostInstance(@NonNull Function<Integer, Spliterator.OfInt> nextVerticesFunction, @NonNull BiFunction<Integer, Integer, Long> costFunction, @NonNull IndexedVertexPathSearchAlgo<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
-
SimpleIndexedVertexSequenceFinder
public SimpleIndexedVertexSequenceFinder(@NonNull C zero, @NonNull Function<Integer, Spliterator.OfInt> nextVerticesFunction, @NonNull BiFunction<Integer, Integer, C> costFunction, @NonNull BiFunction<C, C, C> sumFunction, @NonNull IndexedVertexPathSearchAlgo<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).
-
-
Method Details
-
newIntCostInstance
public static @NonNull SimpleIndexedVertexSequenceFinder<Integer> newIntCostInstance(@NonNull Function<Integer, Spliterator.OfInt> nextVerticesFunction, @NonNull BiFunction<Integer, Integer, Integer> costFunction, @NonNull IndexedVertexPathSearchAlgo<Integer> algo) Creates a new instance which has a cost function that returns integer numbers.- 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
SimpleIndexedVertexSequenceFinderinstance.
-
newIntCostInstance
public static @NonNull SimpleIndexedVertexSequenceFinder<Integer> newIntCostInstance(@NonNull Function<Integer, Spliterator.OfInt> nextVerticesFunction, @NonNull IndexedVertexPathSearchAlgo<Integer> algo) Creates a new instance which has a int cost function that counts the number of arrows.- Parameters:
nextVerticesFunction- a function that given a vertex, returns anIterablefor the next vertices of that vertex.algo- the search algorithm- Returns:
- the new
SimpleIndexedVertexSequenceFinderinstance.
-
newLongCostInstance
public static @NonNull SimpleIndexedVertexSequenceFinder<Long> newLongCostInstance(@NonNull Function<Integer, Spliterator.OfInt> nextVerticesFunction, @NonNull BiFunction<Integer, Integer, Long> costFunction, @NonNull IndexedVertexPathSearchAlgo<Long> algo) Creates a new instance which has a cost function that returns long numbers.- 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
SimpleIndexedVertexSequenceFinderinstance.
-
findVertexSequence
public @Nullable SimpleOrderedPair<ImmutableList<Integer>,C> findVertexSequence(@NonNull Iterable<Integer> startVertices, @NonNull Predicate<Integer> goalPredicate, int maxDepth, @NonNull C costLimit, @NonNull AddToSet<Integer> 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<Integer,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<Integer>,C> findVertexSequenceOverWaypoints(@NonNull Iterable<Integer> waypoints, int maxDepth, @NonNull C costLimit, @NonNull Supplier<AddToSet<Integer>> visitedSetFactory) Description copied from interface:VertexSequenceFinderFinds a vertex sequence through the given waypoints.- Specified by:
findVertexSequenceOverWaypointsin interfaceVertexSequenceFinder<Integer,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.
-