Recursion Trees.qvw

    This example resolves a recursion tree challenge into an associative data model Recursion means a sequence of predecessor-successor relations, where a child node can repeat in different branches of the tree.

     

    As long as a child node has only "one way up" in the tree, you may sufficiently solve this using our HIERARCHY LOAD or HIERARCHYBELONGSTO LOAD functions.

     

    Although inside the app I called the relations "parent-child", please don't think of it like of a natural child, which by nature has only one mother. In this example, it might have multiple, like B2 and C2 in the below graphics.

    dd.png

    The script requires 3 loops and 2 tables to facilitate this and it has a "circular reference" detection to stop execution if wanted. Circular reference happens if a parent repeats further down the tree as a child, which would end in an infinite loop.

     

    There are several parameters to play with (as variables in the load script) togehter with plenty of inline remarks for your understanding.

    For example you can set a maximum depth of levels, decide to stop or abort execution upon detecion of a loop, a separator sign for the combined path string ...

     

    Enjoy,

    Christof Schwarz