| Trees | Indices | Help |
|
|---|
|
|
This is your bog standard Tree class. the root of the tree is just a TreeNode like all other members.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
constructor
**Arguments**
- parent: the parent of this node in the tree
- name: the name of the node
- label: the node's label (should be an integer)
- data: an optional data field
- level: an integer indicating the level of this node in the hierarchy
(used for printing)
- isTerminal: flags a node as being terminal. This is useful for those
times when it's useful to know such things.
|
Set the names of each node in the tree from a list of variable names.
**Arguments**
- varNames: a list of names to be assigned
**Notes**
1) this works its magic by recursively traversing all children
2) The assumption is made here that the varNames list can be indexed
by the labels of tree nodes
|
Set the names of each node in the tree from a list of variable names.
**Arguments**
- varNames: a list of names to be assigned
**Notes**
1) this works its magic by recursively traversing all children
2) The assumption is made here that the varNames list can be indexed
by the labels of tree nodes
|
Adds a TreeNode to the local list of children **Arguments** - node: the node to be added **Note** the level of the node (used in printing) is set as well |
Creates a new TreeNode and adds a child to the tree **Arguments** - name: the name of the new node - label: the label of the new node (should be an integer) - data: the data to be stored in the new node - isTerminal: a toggle to indicate whether or not the new node is a terminal (leaf) node. **Returns* the _TreeNode_ which is constructed |
Removes the child node **Arguments** - child: a TreeNode |
Replaces a given child with a new one **Arguments** - index: an integer - child: a TreeNode |
Returns a python list of the children of this node
|
Destroys this node and all of its children
|
Returns the name of this node
|
Sets the name of this node
|
Returns the data stored at this node
|
Sets the data stored at this node
|
Returns whether or not this node is terminal
|
Sets whether or not this node is terminal
|
Returns the label of this node
|
Sets the label of this node (should be an integer)
|
Returns the level of this node
|
Sets the level of this node
|
Returns the parent of this node
|
Sets the parent of this node
|
Pretty prints the tree **Arguments** - level: sets the number of spaces to be added at the beginning of the output - showData: if this is nonzero, the node's _data_ value will be printed as well **Note** this works recursively |
Pickles the tree and writes it to disk
|
returns a string representation of the tree **Note** this works recursively |
allows tree1 == tree2 **Note** This works recursively |
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0beta1 on Tue Oct 7 06:26:51 2008 | http://epydoc.sourceforge.net |