edu.uci.ics.jung.graph
Interface Tree<V,E>

All Superinterfaces:
DirectedGraph<V,E>, Forest<V,E>, Graph<V,E>, Hypergraph<V,E>
All Known Implementing Classes:
DelegateTree, OrderedKAryTree

public interface Tree<V,E>
extends Forest<V,E>

A subtype of 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.)

Author:
Joshua O'Madadhain

Method Summary
 int getChildCount(V vertex)
          Returns the number of children that vertex has in this tree.
 Collection<E> getChildEdges(V vertex)
          Returns the edges connecting vertex to its children in this tree.
 Collection<V> getChildren(V vertex)
          Returns the children of vertex in this tree.
 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 getParent(V vertex)
          Returns the parent of vertex in this tree.
 E getParentEdge(V vertex)
          Returns the edge connecting vertex to its parent in this tree.
 V getRoot()
          Returns the root of this tree.
 
Methods inherited from interface edu.uci.ics.jung.graph.Forest
getTrees
 
Methods inherited from interface edu.uci.ics.jung.graph.Graph
addEdge, addEdge, getDest, getEndpoints, getInEdges, getOpposite, getOutEdges, getPredecessorCount, getPredecessors, getSource, getSuccessorCount, getSuccessors, inDegree, isDest, isPredecessor, isSource, isSuccessor, outDegree
 
Methods inherited from interface edu.uci.ics.jung.graph.Hypergraph
addEdge, addEdge, addVertex, containsEdge, containsVertex, degree, findEdge, findEdgeSet, getEdgeCount, getEdgeCount, getEdges, getEdges, getEdgeType, getIncidentCount, getIncidentEdges, getIncidentVertices, getNeighborCount, getNeighbors, getVertexCount, getVertices, isIncident, isNeighbor, removeEdge, removeVertex
 

Method Detail

getDepth

int getDepth(V vertex)
Returns the (unweighted) distance of vertex from the root of this tree.

Parameters:
vertex - the vertex whose depth is to be returned.
Returns:
the length of the shortest unweighted path from vertex to the root of this tree
See Also:
getHeight()

getHeight

int getHeight()
Returns the maximum depth in this tree.

Returns:
the maximum depth in this tree
See Also:
getDepth(Object)

getRoot

V getRoot()
Returns the root of this tree. The root is defined to be the vertex (designated either at the tree's creation time, or as the first vertex to be added) with respect to which vertex depth is measured.

Returns:
the root of this tree

getParent

V getParent(V vertex)
Returns the parent of vertex in this tree. (If vertex is the root, returns null.) The parent of a vertex is defined as being its predecessor in the (unique) shortest path from the root to this vertex. This is a convenience method which is equivalent to Graph.getPredecessors(vertex).iterator().next().

Returns:
the parent of vertex in this tree
See Also:
Graph.getPredecessors(Object), getParentEdge(Object)

getParentEdge

E getParentEdge(V vertex)
Returns the edge connecting vertex to its parent in this tree. (If vertex is the root, returns null.) The parent of a vertex is defined as being its predecessor in the (unique) shortest path from the root to this vertex. This is a convenience method which is equivalent to Graph.getInEdges(vertex).iterator().next(), and also to Graph.findEdge(vertex, getParent(vertex)).

Returns:
the edge connecting vertex to its parent, or null if vertex is the root
See Also:
Graph.getInEdges(Object), getParent(Object)

getChildren

Collection<V> getChildren(V vertex)
Returns the children of vertex in this tree. The children of a vertex are defined as being the successors of that vertex on the respective (unique) shortest paths from the root to those vertices. This is syntactic (maple) sugar for getSuccessors(vertex).

Parameters:
vertex - the vertex whose children are to be returned
Returns:
the Collection of children of vertex in this tree
See Also:
Graph.getSuccessors(Object), getChildEdges(Object)

getChildEdges

Collection<E> getChildEdges(V vertex)
Returns the edges connecting vertex to its children in this tree. The children of a vertex are defined as being the successors of that vertex on the respective (unique) shortest paths from the root to those vertices. This is syntactic (maple) sugar for getOutEdges(vertex).

Parameters:
vertex - the vertex whose child edges are to be returned
Returns:
the Collection of edges connecting vertex to its children in this tree
See Also:
Graph.getOutEdges(Object), getChildren(Object)

getChildCount

int getChildCount(V vertex)
Returns the number of children that vertex has in this tree. The children of a vertex are defined as being the successors of that vertex on the respective (unique) shortest paths from the root to those vertices. This is syntactic (maple) sugar for getSuccessorCount(vertex).

Parameters:
vertex - the vertex whose child edges are to be returned
Returns:
the Collection of edges connecting vertex to its children in this tree
See Also:
getChildEdges(Object), getChildren(Object), Graph.getSuccessorCount(Object)


Copyright © 2008 null. All Rights Reserved.