[mmMaxgetnodes] [Up] [mmMaxgetcount] Introspection Functions

mmMaxgetchildren
Returns an array of children of the given node.

Synopsis

Image mmMaxgetchildren ( const MaxTree& maxtree , const Double& level , const Double& 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
// --------------------------------------------------------------
void printNode(MaxTree& mxt, int indent, int level, int index)
{
    int i;
    Image node_stats = mmMaxgetnodes(mxt, level, index);
    int *st = (int *)node_stats.raster();
    for(i = 0; i < indent; i++) printf("  ");
    printf("Node(%d,%d): [%d (%d,%d) (%d,%d -- %d,%d)]\n", level, index, st[3], 
                                                           st[4]/st[3], st[5]/st[3], 
                                                           st[6], st[7], st[8], st[9]);
    // if node is not a leave, print the children
    if(st[0] == 0) {
        Image node_child = mmMaxgetchildren(mxt, level, index);
        int nch = node_child.height();
        int *child = (int *)node_child.raster();
        for(i = 0; i < nch; i++) {
            int lev = *child++;
            int ind = *child++;
            printNode(mxt, indent+1, lev, ind);
        }
    }
}

[mmMaxgetnodes] [Up] [mmMaxgetcount]