[maxgetnodes] [Up] [maxgetcount] Introspection Functions

maxgetchildren
Returns an array of children of the given node.

Synopsis

y = maxgetchildren ( maxtree , level , index )

Input

maxtree MaxTree

The MaxTree.

level Double

Node level.

index Double

Node index.

Output

y Image

Each row is (level, index) of the child.

Description

This function allows tree traversal from the root node to the leaves.

Make sure the node is not a leaf node before calling this function.

For example, the following code snippet print the nodes of the MaxTree recursively, starting on a given node and going to the leaves.

# --------------------------------------------------------------
# Recursive MaxTree print
# --------------------------------------------------------------
def printNode(mxt, indent, level, index):
    st = maxgetnodes(mxt, level, index)
    print '  '*indent
    print 'Node(%d,%d): [%d (%d,%d) (%d,%d -- %d,%d)]' % (level, index, st[3], 
                                                          st[4]/st[3], st[5]/st[3], 
                                                          st[6], st[7], st[8], st[9])
    if st[0] == 0:  # not a leaf
        children = maxgetchildren(mxt, level, index)
        for lev, ind in children:
            printNode(mxt, indent+1, lev, ind)

[maxgetnodes] [Up] [maxgetcount]