Package dev.nm.graph
Interface RootedTree<V,E extends Arc<V>>
-
- Type Parameters:
V
- vertex typeE
- edge type
- All Known Implementing Classes:
SparseTree
,VertexTree
public interface RootedTree<V,E extends Arc<V>> extends Tree<V,E>, DAGraph<V,E>
A rooted tree is a directed graph, and has a root to measure distance from the root.- See Also:
- Wikipedia: Simple graph
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
depth(V v)
Gets the (unweighted) distance of a vertex from the root of the vertex.int
height()
Gets the maximum depth in this tree.V
root()
Gets the root of this tree.RootedTree<V,E>
subTree(V v)
Gets a sub-tree starting from a vertex.-
Methods inherited from interface dev.nm.graph.DAGraph
topologicalOrder
-
Methods inherited from interface dev.nm.graph.DiGraph
children, incomingArcs, outgoingArcs, parents
-
Methods inherited from interface dev.nm.graph.Graph
addEdge, addVertex, edges, edges, removeEdge, removeVertex, vertices
-
-
-
-
Method Detail
-
root
V root()
Gets the root of this tree. The root is defined to be the vertex with respect to which vertex depth is measured.- Returns:
- the root of this tree
-
depth
int depth(V v)
Gets the (unweighted) distance of a vertex from the root of the vertex.- Parameters:
v
- the vertex whose depth is to be computed- Returns:
- the length of the shortest unweighted path from its root to the vertex
-
height
int height()
Gets the maximum depth in this tree.- Returns:
- the maximum depth in this tree
-
subTree
RootedTree<V,E> subTree(V v)
Gets a sub-tree starting from a vertex.- Parameters:
v
- the root of the sub-tree- Returns:
- the sub-tree
-
-