Class BreadthFirstSearch<V>

  • Type Parameters:
    V - the vertex type parameter
    All Implemented Interfaces:
    GraphSearch<V>, Serializable

    public class BreadthFirstSearch<V>
    extends Object

    Performs a breadth first search to find a path between the given starting point and ending point.

    Author:
    David B. Bracewell
    See Also:
    Serialized Form
    • Constructor Detail

      • BreadthFirstSearch

        public BreadthFirstSearch​(Graph<V> graph)
        Instantiates a new BreadthFirstSearch.
        Parameters:
        graph - the graph to search
    • Method Detail

      • search

        public final List<Edge<V>> search​(V startingPoint,
                                          V endingPoint)
        Description copied from interface: GraphSearch
        Searches for a path from the given starting point to the given ending point
        Specified by:
        search in interface GraphSearch<V>
        Parameters:
        startingPoint - the starting point
        endingPoint - the ending point
        Returns:
        the path as a list of edges (empty list if no path exists)