Class DepthFirstSearch<V>

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

    public class DepthFirstSearch<V>
    extends Object

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

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

      • DepthFirstSearch

        public DepthFirstSearch​(Graph<V> graph)
        Instantiates a new DepthFirstSearch.
        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)