OpenBI Docs Buy

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>] )
ParameterTypeDescription
linksTableThe rows that make the network, one link a row: a table of the model or a table expression, as the filters leave it.
fromExpression
evaluated for each row
One end of each row's link, such as a payer, a customer or a place.
toExpression
evaluated for each row
The other end of each row's link.
capacityExpression
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.
sourceValueThe node the flow starts from.
targetValueThe node the flow goes to.
directedBoolean
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 )
FromToCapacityFlowCutMax flow
BreweryDepot N87FALSE13
BreweryDepot S76FALSE13
Depot NDepot S33FALSE13
Depot NShop44TRUE13
Depot SShop99TRUE13

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.

Last updated · OpenBI Studio 0.3.78