Associative operators
Associative operators are used to perform binary operations on two or more inputs. These types of operators are useful for mathematical operations. The add
, subtract
, multiply
, and matrix_multiply
Bifrost nodes are all associative nodes.
When only two input ports are connected, the associative operator acts as a binary operator. When three or more input ports are connected, the inputs are automatically grouped together in an associative manner based on the value assigned to the operator's associativity, which can be left-to-right or right-to-left.
In left-to-right associativity, inputs are grouped associatively starting from the first input port:
Port1 + Port2 + Port3 + Port4 => (((Port1 + Port2) + Port3) + Port4)
In right-to-left associativity, inputs are grouped associatively starting from the last input port:
Port1 + Port2 + Port3 + Port4 => (Port1 + (Port2 + (Port3 + Port4)))
Associativity can be conceptualized as connecting multiple instances of the binary version of the node in a cascading graph.
For example, the left-to-right associative node on the left is equivalent to the cascade of binary nodes on the right:
![]() |
![]() |
---|---|
The left-to-right associative node produces the same result as a cascade of binary nodes | Both these graphs produce the same result: (((1+2)+3)+4) |
And the right-to-left associative node on the left is equivalent to the cascade of binary nodes on the right:
![]() |
![]() |
---|---|
This right-to-left associative node produces the same result as a cascade of binary nodes | Both these graphs produce the same result: (1+(2+(3+4))) |
See sdk/examples/SimpleAssociative in your installation for an example of associativity.