Package at.jku.ssw.fp.sect04_3
Class SearchAlgos
- java.lang.Object
-
- at.jku.ssw.fp.sect04_3.SearchAlgos
-
public class SearchAlgos extends Object
Class with search methods.- Author:
- Herbert Praehofer
-
-
Field Summary
Fields Modifier and Type Field Description private static boolean
DEBUG
static int
nodesVisited
-
Constructor Summary
Constructors Constructor Description SearchAlgos()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <N> Optional<N>
bestFirstSearch(Function<N,List<N>> succFn, Function<N,Integer> weightingFn, Predicate<N> goalFn, N start)
Implements a best-first search algorithm.static <N> Optional<N>
breadthFirstSearch(Function<N,List<N>> succFn, Predicate<N> goalFn, N start)
Implements a breadth-first search algorithm.static <N> Optional<N>
depthFirstSearch(Function<N,List<N>> succFn, Predicate<N> goalFn, N start)
Implements a depth-first search algorithm.
-
-
-
Field Detail
-
DEBUG
private static final boolean DEBUG
- See Also:
- Constant Field Values
-
nodesVisited
public static int nodesVisited
-
-
Method Detail
-
depthFirstSearch
public static <N> Optional<N> depthFirstSearch(Function<N,List<N>> succFn, Predicate<N> goalFn, N start)
Implements a depth-first search algorithm.- Type Parameters:
N
- the type of nodes- Parameters:
succFn
- the successor functiongoalFn
- the goal functionstart
- the start node- Returns:
- the found node in an optional, if exists, empty otherwise.
-
breadthFirstSearch
public static <N> Optional<N> breadthFirstSearch(Function<N,List<N>> succFn, Predicate<N> goalFn, N start)
Implements a breadth-first search algorithm.- Type Parameters:
N
- the type of nodes- Parameters:
succFn
- the successor functiongoalFn
- the goal functionstart
- the start node- Returns:
- the found node in an optional, if exists, empty otherwise.
-
bestFirstSearch
public static <N> Optional<N> bestFirstSearch(Function<N,List<N>> succFn, Function<N,Integer> weightingFn, Predicate<N> goalFn, N start)
Implements a best-first search algorithm.- Type Parameters:
N
- the type of nodes- Parameters:
succFn
- the successor functionweightingFn
- the function for ordering the nodesgoalFn
- the goal functionstart
- the start node- Returns:
- the found node in an optional, if exists, empty otherwise.
-
-