V
- vertex typepublic class DFS<V> extends TraversalFromRoots<V> implements GraphTraversal<V>
Modifier and Type | Class and Description |
---|---|
static class |
DFS.Node<V>
This is a node in a DFS-spanning tree.
|
g
Constructor and Description |
---|
DFS(Graph<? extends V,? extends Edge<V>> g)
Constructs a DFS tree of a graph.
|
Modifier and Type | Method and Description |
---|---|
static <V,W extends V> |
DFS(Graph<W,? extends Edge<V>> g,
V root,
int time)
Runs the depth-first-search on a graph from a designated root.
|
List<DFS.Node<V>> |
getOrderedNodes()
Gets the collection of visited nodes to build a spanning tree.
|
boolean |
isCyclic()
Checks if the graph is cyclic.
|
List<DFS.Node<V>> |
track(V root,
int time)
Runs the traversal algorithm on a graph from a designated root.
|
traverse
public List<DFS.Node<V>> track(V root, int time)
TraversalFromRoots
track
in class TraversalFromRoots<V>
root
- a roottime
- the initial timepublic static <V,W extends V> List<DFS.Node<V>> DFS(Graph<W,? extends Edge<V>> g, V root, int time)
V
- vertex typeg
- a graphroot
- a roottime
- the initial timepublic List<DFS.Node<V>> getOrderedNodes()
TraversalFromRoots
getOrderedNodes
in interface GraphTraversal<V>
getOrderedNodes
in class TraversalFromRoots<V>
public boolean isCyclic()
true
if the graph is cyclicCopyright © 2010-2020 NM FinTech Ltd.. All Rights Reserved.