# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.graph

## Interface RootedTree<V,E extends Arc<V>>

• Type Parameters:
V - vertex type
E - edge type
All Superinterfaces:
DAGraph<V,E>, DiGraph<V,E>, Graph<V,E>, Tree<V,E>
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.
Wikipedia: Simple graph
• ### Method Summary

All Methods
Modifier and Type Method and 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 com.numericalmethod.suanshu.graph.Tree

parent
• ### Methods inherited from interface com.numericalmethod.suanshu.graph.DAGraph

topologicalOrder
• ### Methods inherited from interface com.numericalmethod.suanshu.graph.DiGraph

children, incomingArcs, outgoingArcs, parents
• ### Methods inherited from interface com.numericalmethod.suanshu.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