Module org.jhotdraw8.graph
Package org.jhotdraw8.graph.path
Class SimpleReachabilityChecker<V,A,C extends Number & Comparable<C>>
java.lang.Object
org.jhotdraw8.graph.path.SimpleReachabilityChecker<V,A,C>
- Type Parameters:
V- the vertex data typeA- the arrow data typeC- the cost number type
- All Implemented Interfaces:
ReachabilityChecker<V,C>
public class SimpleReachabilityChecker<V,A,C extends Number & Comparable<C>>
extends Object
implements ReachabilityChecker<V,C>
Implements the
ReachabilityChecker interface.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanisReachable(@NonNull V start, @NonNull V goal, int maxDepth, @NonNull C costLimit, @NonNull AddToSet<V> visited) Checks if a vertex sequence from start to goal exists.booleanisReachable(@NonNull V start, @NonNull Predicate<V> goalPredicate, int maxDepth, @NonNull C costLimit, @NonNull AddToSet<V> visited) Checks if a vertex sequence from a start vertex to a vertex that satisfies the goal predicate exists.booleanisReachable(@NonNull Iterable<V> startVertices, @NonNull Predicate<V> goalPredicate, int maxDepth, @NonNull C costLimit, @NonNull AddToSet<V> visited) Checks if a vertex sequence from a set of start vertices to a vertex that satisfies the goal predicate exists.static <VV,AA> @NonNull SimpleReachabilityChecker <VV, AA, Integer> newIntCostInstance(@NonNull Function<VV, Iterable<Arc<VV, AA>>> nextArcsFunction, @NonNull Function3<VV, VV, AA, Integer> costFunction, @NonNull ArcReachabilityAlgo<VV, AA, Integer> algo) Creates a new instance which has a cost function that returns integer numbers.static <VV,AA> @NonNull SimpleReachabilityChecker <VV, AA, Integer> newIntCostInstance(@NonNull Function<VV, Iterable<Arc<VV, AA>>> nextArcsFunction, @NonNull ArcReachabilityAlgo<VV, AA, Integer> algo) Creates a new instance which has a int cost function that counts the number of arrows.static <VV,AA> @NonNull SimpleReachabilityChecker <VV, AA, Long> newLongCostInstance(@NonNull Function<VV, Iterable<Arc<VV, AA>>> nextArcsFunction, @NonNull Function3<VV, VV, AA, Long> costFunction, @NonNull ArcReachabilityAlgo<VV, AA, Long> algo) Creates a new instance which has a cost function that returns long numbers.
-
Constructor Details
-
SimpleReachabilityChecker
public SimpleReachabilityChecker(@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 ArcReachabilityAlgo<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 SimpleReachabilityChecker<VV,AA, newIntCostInstanceInteger> (@NonNull Function<VV, Iterable<Arc<VV, AA>>> nextArcsFunction, @NonNull Function3<VV, VV, AA, Integer> costFunction, @NonNull ArcReachabilityAlgo<VV, AA, Integer> algo) Creates a new instance which has a cost function that returns integer numbers.- Type Parameters:
VV- the vertex data type- Parameters:
nextArcsFunction- a function that given a vertex, returns anIterablefor the arcs of that vertex.costFunction- the cost functionalgo- the search algorithm- Returns:
- the new
SimpleReachabilityCheckerinstance.
-
newIntCostInstance
public static <VV,AA> @NonNull SimpleReachabilityChecker<VV,AA, newIntCostInstanceInteger> (@NonNull Function<VV, Iterable<Arc<VV, AA>>> nextArcsFunction, @NonNull ArcReachabilityAlgo<VV, AA, 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:
nextArcsFunction- a function that given a vertex, returns anIterablefor the arcs of that vertex.algo- the search algorithm- Returns:
- the new
SimpleReachabilityCheckerinstance.
-
newLongCostInstance
public static <VV,AA> @NonNull SimpleReachabilityChecker<VV,AA, newLongCostInstanceLong> (@NonNull Function<VV, Iterable<Arc<VV, AA>>> nextArcsFunction, @NonNull Function3<VV, VV, AA, Long> costFunction, @NonNull ArcReachabilityAlgo<VV, AA, Long> algo) Creates a new instance which has a cost function that returns long numbers.- Type Parameters:
VV- the vertex data type- Parameters:
nextArcsFunction- a function that given a vertex, returns anIterablefor the arcs of that vertex.costFunction- the cost functionalgo- the search algorithm- Returns:
- the new
SimpleReachabilityCheckerinstance.
-
isReachable
public boolean isReachable(@NonNull Iterable<V> startVertices, @NonNull Predicate<V> goalPredicate, int maxDepth, @NonNull C costLimit, @NonNull AddToSet<V> visited) Description copied from interface:ReachabilityCheckerChecks if a vertex sequence from a set of start vertices to a vertex that satisfies the goal predicate exists.- Specified by:
isReachablein interfaceReachabilityChecker<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 function- Returns:
- true if a sequence was found.
-
isReachable
public boolean isReachable(@NonNull V start, @NonNull Predicate<V> goalPredicate, int maxDepth, @NonNull C costLimit, @NonNull AddToSet<V> visited) Description copied from interface:ReachabilityCheckerChecks if a vertex sequence from a start vertex to a vertex that satisfies the goal predicate exists.- Specified by:
isReachablein interfaceReachabilityChecker<V,A> - Parameters:
start- the start vertexgoalPredicate- the goal vertexmaxDepth- the maximal depth (inclusive) of the search Must be >= 0.costLimit- the algorithm-specific cost limitvisited- the visited function- Returns:
- true if a sequence was found.
-
isReachable
public boolean isReachable(@NonNull V start, @NonNull V goal, int maxDepth, @NonNull C costLimit, @NonNull AddToSet<V> visited) Description copied from interface:ReachabilityCheckerChecks if a vertex sequence from start to goal exists.- Specified by:
isReachablein interfaceReachabilityChecker<V,A> - Parameters:
start- the start vertexgoal- the goal vertexmaxDepth- the maximal depth (inclusive) of the search Must be >= 0.costLimit- the algorithm-specific cost limitvisited- the visited function- Returns:
- true if a sequence was found.
-