public interface Tree<V,E> extends Forest<V,E>
Graph
which is a (directed, rooted) tree.
What we refer to as a "tree" here is actually (in the terminology of graph theory) a
rooted tree. (That is, there is a designated single vertex--the root--from which we measure
the shortest path to each vertex, which we call its depth; the maximum over all such
depths is the tree's height. Note that for a tree, there is exactly
one unique path from the root to any vertex.)Modifier and Type | Method and Description |
---|---|
int |
getDepth(V vertex)
Returns the (unweighted) distance of
vertex
from the root of this tree. |
int |
getHeight()
Returns the maximum depth in this tree.
|
V |
getRoot()
Returns the root of this tree.
|
getChildCount, getChildEdges, getChildren, getParent, getParentEdge, getTrees
addEdge, addEdge, getDest, getEndpoints, getInEdges, getOpposite, getOutEdges, getPredecessorCount, getPredecessors, getSource, getSuccessorCount, getSuccessors, inDegree, isDest, isPredecessor, isSource, isSuccessor, outDegree
addEdgeWithVertices, addEdgeWithVertices, addVertex, containsEdge, containsVertex, degree, findEdge, findEdgeSet, getDefaultEdgeType, getEdgeCount, getEdgeCount, getEdges, getEdgesView, getEdgeType, getIncidentCount, getIncidentEdges, getIncidentVertices, getNeighborCount, getNeighbors, getVertexCount, getVerticesView, isIncident, isNeighbor, removeEdge, removeVertex
int getDepth(V vertex)
vertex
from the root of this tree.vertex
- the vertex whose depth is to be returned.vertex
to the root of this treegetHeight()
int getHeight()
getDepth(Object)
V getRoot()
Copyright © 2021, 2022 Herve Girod. All Rights Reserved. Documentation and source under the BSD 3-Clause licence