Class WNode
java.lang.Object
|
+----WNode
- public class WNode
- extends Object
Represents a node (or tree) in the WalTree.
This is part of the WalTree package, created by Walter Korman to enable
the visually appealing display of M-ary trees. More documentation is
available at his web site; follow the link below to get to it.
Documentation
Added by Naomi Novik:
The boolean field "visited" and the "visit" and "leave" methods were added
for use in displaying a search as it progresses through a tree. The
methods expand(), getNodeDepth(), and getTreeDepth() were added to help
with searching functions,
so that calling classes don't need to know what the member fields of the WNode
are. The toString() method was added for the same reason.
- Author:
- Walter Korman, Naomi Novik
-
WNode(String, WNode, WNode, WNode, int, int, int)
-
-
expand()
-
Expand a node, returning a Vector containing its
children.
-
getNodeDepth()
- Determine depth of node within the tree.
-
getTreeDepth()
- Determine maximum depth of tree rooted at this node.
-
leave()
-
Change the visited status of the node to false.
-
toString()
- Return the label of the node.
-
visit()
- Change the visited status of the node to true.
WNode
public WNode(String l,
WNode p,
WNode c,
WNode s,
int w,
int h,
int b)
toString
public String toString()
- Return the label of the node.
- Overrides:
- toString in class Object
visit
public void visit()
- Change the visited status of the node to true.
leave
public void leave()
- Change the visited status of the node to false.
expand
public Vector expand()
- Expand a node, returning a Vector containing its
children.
getNodeDepth
public int getNodeDepth()
- Determine depth of node within the tree.
The number of parents the node has represents its depth,
assuming the root has depth 0.
getTreeDepth
public int getTreeDepth()
- Determine maximum depth of tree rooted at this node.
Assuming an even distribution, this is until there
are no more children in a straight line from the root.