public class ForestTreeAdapter extends Object implements RootedTree
OrientedForest rooted at a specified node as a RootedTree.| Constructor and Description |
|---|
ForestTreeAdapter(Object root,
OrientedForest forest,
boolean isStrict)
Creates a new
ForestTreeAdapter. |
| Modifier and Type | Method and Description |
|---|---|
Traverser |
childTraverser(Object node)
Traverses over the children of the specified node.
|
int |
getDepth(Object node)
Gets the depth of the specified node.
|
int |
getHeight(Object node)
Gets the height of the specified node.
|
Object |
getLeastCommonAncestor(Object aNode,
Object bNode)
Returns the least common ancestor of the specified nodes, or
null if none exists. |
Object |
getParent(Object node)
Gets the parent of the specified node, or
null if
it doesn't have one. |
Graph.Edge |
getParentEdge(Object node)
Gets the parent
Edge of the specified node, or
null if it doesn't have one. |
Object |
getParentEndpoint(Graph.Edge edge)
Returns the parent endpoint of the specified forest
Edge. |
Object |
getRoot()
Gets the root node.
|
Object |
getRoot(Object node)
Gets the root of the subgraph containing the specified node.
|
boolean |
isAncestor(Object ancestor,
Object descendant)
Returns
true if ancestor is actually
an ancestor of descendant. |
boolean |
isForestEdge(Graph.Edge edge)
Gets whether or not the specified
Edge is a
forest edge. |
boolean |
isLeaf(Object node)
Returns
true if the specified node has no
children. |
boolean |
isTreeNode(Object node)
Returns
true if the specified node is a
descendant of the root node. |
Collection |
rootNodes()
Returns the root nodes of this forest.
|
void |
setRoot(Object root)
Sets the root node, which must already be present.
|
public ForestTreeAdapter(Object root, OrientedForest forest, boolean isStrict)
ForestTreeAdapter.root - create a tree of the subgraph rooted at this
node.forest - the forest of which this tree is a subview.isStrict - if true, all appropriate methods
accepting nodes will throw a NoSuchNodeException
if the argument node is not a descendant of the root node of
this tree. If false, only getRoot( node ) and getDepth( node ) will throw an exception in this case.public void setRoot(Object root)
Rootedpublic Object getParent(Object node)
OrientedForestnull if
it doesn't have one. If null is a valid node,
then OrientedForest.getParentEdge(java.lang.Object) must be used to distinguish the
two cases.getParent in interface OrientedForestpublic Traverser childTraverser(Object node)
OrientedForestchildTraverser in interface OrientedForestpublic Graph.Edge getParentEdge(Object node)
OrientedForestEdge of the specified node, or
null if it doesn't have one.getParentEdge in interface OrientedForestpublic boolean isForestEdge(Graph.Edge edge)
OrientedForestEdge is a
forest edge.isForestEdge in interface OrientedForestpublic Object getParentEndpoint(Graph.Edge edge)
OrientedForestEdge. If the specified Edge is not
a forest edge, throws an
IllegalArgumentException.getParentEndpoint in interface OrientedForestpublic Collection rootNodes()
OrientedForestrootNodes in interface OrientedForestpublic Object getRoot(Object node)
OrientedForestgetRoot in interface OrientedForestpublic boolean isLeaf(Object node)
OrientedForesttrue if the specified node has no
children.isLeaf in interface OrientedForestpublic boolean isAncestor(Object ancestor, Object descendant)
OrientedForesttrue if ancestor is actually
an ancestor of descendant.isAncestor in interface OrientedForestpublic Object getLeastCommonAncestor(Object aNode, Object bNode)
OrientedForestnull if none exists. If null is a
valid node, then some other method must be used to distinguish
the two cases.getLeastCommonAncestor in interface OrientedForestpublic int getDepth(Object node)
OrientedForestgetDepth in interface OrientedForestpublic int getHeight(Object node)
OrientedForestgetHeight in interface OrientedForestpublic boolean isTreeNode(Object node)
RootedTreetrue if the specified node is a
descendant of the root node.isTreeNode in interface RootedTreeSee the Plexus project home, hosted by SourceForge.
Copyright ? 1994-2006, by Phoenix Software Technologists, Inc. and others. All Rights Reserved. Use is subject to license terms.