Class DFS<V>

    • Constructor Detail

      • DFS

        public DFS​(Graph<? extends V,​? extends Edge<V>> g)
        Constructs a DFS tree of a graph.
        Parameters:
        g - a graph
    • Method Detail

      • track

        public List<DFS.Node<V>> track​(V root,
                                       int time)
        Description copied from class: TraversalFromRoots
        Runs the traversal algorithm on a graph from a designated root.
        Specified by:
        track in class TraversalFromRoots<V>
        Parameters:
        root - a root
        time - the initial time
        Returns:
        the nodes visited
      • DFS

        public static <V,​W extends V> List<DFS.Node<V>> DFS​(Graph<W,​? extends Edge<V>> g,
                                                                  V root,
                                                                  int time)
        Runs the depth-first-search on a graph from a designated root.
        Type Parameters:
        V - vertex type
        Parameters:
        g - a graph
        root - a root
        time - the initial time
        Returns:
        the nodes visited
      • isCyclic

        public boolean isCyclic()
        Checks if the graph is cyclic.
        Returns:
        true if the graph is cyclic