leaf function in the Factory

The leaf function returns the corresponding leaf for each node of the son attribute. The leaf is the very last node of the branch in a directed graph.

Parameters

leaf(parent, son, group, whichpath, separator, weights, operator)

Parameter

Description

parent

The attribute containing the parent nodes of a directed graph. The parent parameter is mandatory.

son

The attribute containing the son nodes of a directed graph. The son parameter is mandatory.

group

The attribute by which you want to further group results.

The group parameter can also be defined as a list: leaf($"parent",$"son",($"group1", $"group2"))

whichpath

When defined, it allows the user to choose which path is to be considered:

  • the shortest one - whichpath = "minimum",

  • the longest one - whichpath ="maximum" or

  • all the paths - whichpath = "all" - in this case, leafs are concatenated in a single string.

If no path is specified, the leaf function applies the “minimum” variable by default.

separator

It specifies the separator to use in the concatenation of different leafs.

The default separator is "-"

This parameter can only be used when the whichpath = "all" is defined.

weights

The attribute defining the length of the edge.

operator

It defines how to combine weights attributes along the path to the leaf.

If left unspecified, the default operator applied is sum and the weight attributes will be summed. While if the operator is prod, they will be multiplied.

It can only be used if the weights parameter is specified.


Example - leaf(parent,son)

The following example uses the Master datadataset.

Description

Screenshot

In this example, we want to retrieve the corresponding leaf for each node.

In the leaf function, we need to define which attribute is the parent, and which is the son.

So, the formula would be: leaf($"LocFr",$"LocTo")

Here we see the result we have obtained with the leaf function, and we now know what’s the corresponding leaf for each value in the son attribute.