NETWORK.FLOW OpenBI
The maximum flow between two nodes, and its cut.
Group: Networks. OpenBI’s own: DAX has no function of this name.
Syntax
NETWORK.FLOW ( <links>, <from>, <to>, <capacity>, <source>, <target> [, <directed>] )
| Parameter | Type | Description |
|---|---|---|
links | Table | The rows that make the network, one link a row: a table of the model or a table expression, as the filters leave it. |
from | Expression evaluated for each row | One end of each row's link, such as a payer, a customer or a place. |
to | Expression evaluated for each row | The other end of each row's link. |
capacity | Expression evaluated for each row | The most each row's link can carry, never negative. Several rows between the same two nodes add up; BLANK () counts every row as 1. |
source | Value | The node the flow starts from. |
target | Value | The node the flow goes to. |
directed | Boolean optional | TRUE when each link runs one way, from its first end to its second. FALSE or left out, a link works both ways. |
Returns
Table. A row a link, with the columns From, To, Capacity, Flow, Cut and Max flow.
Remarks
- Max flow is the most that can go from the source to the target at once, the same on every row; Flow is how much of it each link carries.
- Cut is TRUE for the links of a minimum cut: the bottleneck, whose capacities add up to the max flow.
- Not directed, a link carries flow either way; a negative Flow runs from To to From. Its ends are listed in the nodes' order, the smaller value first.
- The source and the target must be two different nodes of the network; otherwise the call is an error.
- With every capacity 1, the max flow is the number of paths from the source to the target that share no link.
- When more than one flow reaches the max flow, one of them is given, the same one whatever the order of the rows.
Compared with DAX
An OpenBI function: DAX has none like it, so a measure or query that uses it works in OpenBI only, not in Power BI or Analysis Services.
Examples
Crates a day from the brewery to the shop
13 crates a day get through: the two roads into the shop are the bottleneck.
EVALUATE
VAR Roads =
DATATABLE (
"From", STRING, "To", STRING, "Crates", INTEGER,
{
{ "Brewery", "Depot N", 8 }, { "Brewery", "Depot S", 7 }, { "Depot N", "Depot S", 3 },
{ "Depot N", "Shop", 4 }, { "Depot S", "Shop", 9 }
}
)
RETURN
NETWORK.FLOW ( Roads, [From], [To], [Crates], "Brewery", "Shop", TRUE )
| From | To | Capacity | Flow | Cut | Max flow |
|---|---|---|---|---|---|
| Brewery | Depot N | 8 | 7 | FALSE | 13 |
| Brewery | Depot S | 7 | 6 | FALSE | 13 |
| Depot N | Depot S | 3 | 3 | FALSE | 13 |
| Depot N | Shop | 4 | 4 | TRUE | 13 |
| Depot S | Shop | 9 | 9 | TRUE | 13 |
Related functions
NETWORK.PATH, NETWORK.CYCLES, NETWORK.REACH, OPTIMIZE.
Open Graph, OpenBI's graph library, does the work: maxflow. See the OAX network functions and Open Graph.