com.phoenixst.plexus

Interface OrientedForest

public interface OrientedForest

A data structure with parent/child relationships. Each node may have at most one adjacent node distinguished as being its "parent", and the data structure should be acyclic under the parent operation. The following are definitions for other terms used here (and elsewhere):

The word "oriented" was chosen instead of the more commonly used "directed" because the directedness of the edges need not have any bearing on the parent-child relationships.

Since: 1.0

Version: $Revision: 1.2 $

Author: Ray A. Conner

Method Summary
TraverserchildTraverser(Object node)
Traverses over the children of the specified node.
intgetDepth(Object node)
Gets the depth of the specified node.
intgetHeight(Object node)
Gets the height of the specified node.
ObjectgetLeastCommonAncestor(Object aNode, Object bNode)
Returns the least common ancestor of the specified nodes, or null if none exists.
ObjectgetParent(Object node)
Gets the parent of the specified node, or null if it doesn't have one.
Graph.EdgegetParentEdge(Object node)
Gets the parent Edge of the specified node, or null if it doesn't have one.
ObjectgetParentEndpoint(Graph.Edge edge)
Returns the parent endpoint of the specified forest Edge.
ObjectgetRoot(Object node)
Gets the root of the subgraph containing the specified node.
booleanisAncestor(Object ancestor, Object descendant)
Returns true if ancestor is actually an ancestor of descendant.
booleanisForestEdge(Graph.Edge edge)
Gets whether or not the specified Edge is a forest edge.
booleanisLeaf(Object node)
Returns true if the specified node has no children.
CollectionrootNodes()
Returns the root nodes of this forest.

Method Detail

childTraverser

public Traverser childTraverser(Object node)
Traverses over the children of the specified node.

getDepth

public int getDepth(Object node)
Gets the depth of the specified node.

getHeight

public int getHeight(Object node)
Gets the height of the specified node.

getLeastCommonAncestor

public Object getLeastCommonAncestor(Object aNode, Object bNode)
Returns the least common ancestor of the specified nodes, or null if none exists. If null is a valid node, then some other method must be used to distinguish the two cases.

getParent

public Object getParent(Object node)
Gets the parent of the specified node, or null if it doesn't have one. If null is a valid node, then OrientedForest must be used to distinguish the two cases.

getParentEdge

public Graph.Edge getParentEdge(Object node)
Gets the parent Edge of the specified node, or null if it doesn't have one.

getParentEndpoint

public Object getParentEndpoint(Graph.Edge edge)
Returns the parent endpoint of the specified forest Edge. If the specified Edge is not a forest edge, throws an IllegalArgumentException.

getRoot

public Object getRoot(Object node)
Gets the root of the subgraph containing the specified node.

isAncestor

public boolean isAncestor(Object ancestor, Object descendant)
Returns true if ancestor is actually an ancestor of descendant.

isForestEdge

public boolean isForestEdge(Graph.Edge edge)
Gets whether or not the specified Edge is a forest edge.

isLeaf

public boolean isLeaf(Object node)
Returns true if the specified node has no children.

rootNodes

public Collection rootNodes()
Returns the root nodes of this forest.
See the Plexus project home, hosted by SourceForge.
Copyright B) 1994-2006, by Phoenix Software Technologists, Inc. and others. All Rights Reserved. Use is subject to license terms.