Wiki

Clone wiki

Tree Visualization API / order

Operator.js

connectTofillorderreshaperotatescalesetStrokeColorsetStrokeWidthslicesquarifystriptranslate

Function Order

Organize the nodes of a level based on the specified node attribute .
Recommended stage: PREPROCESS

Function definition


order(mode, attribute, condition)

       

Mode specifies the sorting order. There are three choices for mode

  • ASCENDING (lowest number to highest number)
  • DESCENDING(highest number to lowest number)
  • SHUFFLE (random order)

Attribute specifies the value on which the sorting will be applied.

  • "leaves" (sort the node using the number of leaves)
  • "depth" (sort the node using the depth value of the level)

Parameters details


mode      =  (ASCENDING|DESCENDING|SHUFFLE)
attribute =  ("leaves"|"children"|"depth"|”strahlernum”)  //Only relevant for ASCENDING+DESCENDING
condition = Optional condition if operator is to be carried out. If left out, it is assumed TRUE

Example


The following example code order the nodes in each level , of the tree based on the number of leaves rooted on the sub-tree of that node.

//Order the nodes in ASCENDING order based on the number of leaves.
PREPROCESS:
{
 order(ASCENDING, "leaves"); 
}

Figure:
From the output figure we can see that the tree is sorted in a way so that subtree with lowest number of leaves are placed left side and highest leaves on the right side. Order Ascending From the figure we can see that nodes are sorted based on the number of leaves smallest to largest(Left to right)

Updated