assoc.quantity
assoc.quantity, vector
def vector assoc.quantity(
left: text,
leftQuantity: number,
right: text,
rightQuantity: number) : number
This vector function associates quantities from two sets connected by edges. Given two sets, left and right, represented by the left
and right
groups, the process takes the list of (left, right) edges connecting the two sets. Each set element has an associated initial quantity same(leftQuantity) by left
or same(rightQuantity) by right
. This quantity decreases over the course of the algorithm. Edges are visited in the specified order. The return value for the edge is set to the minimum of the two nodes’ current quantity (the associated quantity), and that value is then subtracted from both quantities. In consequence, once a node’s quantity reaches zero, it no longer contributes to the algorithm. If a by
grouping is provided, each group is treated independently from all others.
Arguments
left: text
— the identifier for the left set.leftQuantity: number
— the initial quantity for each element in the left set.right: text
— the identifier for the right set.rightQuantity: number
— the initial quantity for each element in the right set.
Example
table Edges = with
[| as Left, as LeftQuantity, as Right, as RightQuantity |]
[| "A", 10, "X", 6 |]
[| "A", 10, "Y", 4 |]
[| "B", 8, "X", 6 |]
[| "B", 8, "Z", 3 |]
Edges.Result = assoc.quantity(Edges.Left, Edges.LeftQuantity, Edges.Right, Edges.RightQuantity) sort Edges.Left
show table "Assoc Quantity" with
Edges.Left
Edges.Right
Edges.Result
This outputs the following table:
Left | Right | Result |
---|---|---|
A | X | 6 |
A | Y | 4 |
B | X | 0 |
B | Z | 3 |