OpenBI Docs Buy

NETWORK.LINKS OpenBI

Measures every link of the network a table's rows make, as NETWORK.NODES does every node: its betweenness, whether it is a bridge and which block it is in.

Group: Networks. OpenBI’s own: DAX has no function of this name.

Syntax

NETWORK.LINKS ( <links>, <from>, <to> [, <weight>] [, <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.
weightExpression
optional, evaluated for each row
How heavy each row's link is, such as an amount or a count; never negative. Left out, or given as the constant BLANK (), every row weighs 1.
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, Weight, Betweenness, Bridge and Block.

Remarks

  • Betweenness adds up, over the pairs of nodes, the share of their shortest paths (in hops) that run along the link, the pair it joins included. The only road between two parts of a network scores high. The weights don't change it: every link is one hop.
  • Directed, the paths follow the links' direction, and two nodes linked both ways make two rows.
  • Bridge is TRUE when losing the link alone splits its part of the network: among the links, what a cut point of NETWORK.NODES is among the nodes.
  • Block numbers the network's blocks: the parts that stay in one piece whichever one of their nodes is lost. A bridge is a block of its own. 1 is the block with the most nodes, then the most links; between two alike, the one whose first link comes first.
  • Bridge and Block take the links both ways: two nodes linked both ways are one link to them, and both its rows say the same.
  • The links come as NETWORK.EDGES lists them: by their first end, then their second, in the nodes' order; not directed, a link's smaller value is its From.
  • On a very large network (nodes times links above four billion), betweenness counts only the shortest paths of up to five hops.
  • Several rows between the same two nodes make one link, and their weights add up. Without a weight each row adds 1, so a pair that appears three times weighs 3.
  • With a weight, a row whose weight is blank or 0 adds no link either.
  • Rows where an end is blank, or where both ends are the same node, add no link; the end that is there still counts as a node.
  • To give a later argument without an earlier optional one, leave that one empty, with nothing between the commas: ( Payments, [Payer], [Payee], , TRUE ) is directed and unweighted.
  • In a measure, the table is the rows the filters leave, so the network follows the slicers and the page: a visual measures the network of the rows in view.

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

The links that hold seven friends together

The link between Cy and Di, the only one between the two triangles, carries the most shortest paths: 12, every pair from one side to the other. It is a bridge, as is Fay's link to Gus; each triangle is a block.

EVALUATE
VAR Links =
    DATATABLE (
        "From", STRING, "To", STRING,
        {
            { "Ann", "Bo" }, { "Ann", "Cy" }, { "Bo", "Cy" }, { "Cy", "Di" },
            { "Di", "Ed" }, { "Ed", "Fay" }, { "Di", "Fay" }, { "Fay", "Gus" }
        }
    )
RETURN
    NETWORK.LINKS ( Links, [From], [To] )
FromToWeightBetweennessBridgeBlock
AnnBo11FALSE1
AnnCy15FALSE1
BoCy15FALSE1
CyDi112TRUE3
DiEd14FALSE2
DiFay18FALSE2
EdFay12FALSE2
FayGus16TRUE4

The roads a supply chain can't lose

The loop of the supplier, the two plants and Depot N is block 1: any one of its roads can close and the rest still connects. Every other road is a bridge. The road between Plant B and Depot S carries 18 shortest paths, the 18 pairs NETWORK.WEAKPOINTS says its loss would cut.

EVALUATE
VAR Chain =
    DATATABLE (
        "From", STRING, "To", STRING, "Pallets", INTEGER,
        {
            { "Supplier", "Plant A", 40 }, { "Supplier", "Plant B", 25 }, { "Plant A", "Depot N", 30 },
            { "Plant B", "Depot N", 10 }, { "Plant B", "Depot S", 20 }, { "Depot N", "Shop 1", 12 },
            { "Depot N", "Shop 2", 9 }, { "Depot S", "Shop 3", 14 }, { "Shop 3", "Shop 4", 6 }
        }
    )
RETURN
    NETWORK.LINKS ( Chain, [From], [To], [Pallets] )
FromToWeightBetweennessBridgeBlock
Depot NPlant A306.5FALSE1
Depot NPlant B1015.5FALSE1
Depot NShop 1128TRUE2
Depot NShop 298TRUE3
Depot SPlant B2018TRUE4
Depot SShop 31414TRUE5
Plant ASupplier404.5FALSE1
Plant BSupplier257.5FALSE1
Shop 3Shop 468TRUE6

Payments one way

Directed, the paths follow the money: the payment from D to E lies on the most of them. E to F is the only bridge.

EVALUATE
VAR Payments =
    DATATABLE (
        "Payer", STRING, "Payee", STRING, "Amount", INTEGER,
        {
            { "A", "B", 100 }, { "B", "C", 80 }, { "C", "A", 60 }, { "C", "D", 50 },
            { "D", "E", 40 }, { "E", "C", 30 }, { "E", "F", 20 }
        }
    )
RETURN
    NETWORK.LINKS ( Payments, [Payer], [Payee], [Amount], TRUE )
FromToWeightBetweennessBridgeBlock
AB1008FALSE1
BC809FALSE1
CA607FALSE1
CD5010FALSE2
DE4011FALSE2
EC307FALSE2
EF205TRUE3

NETWORK.NODES, NETWORK.EDGES, NETWORK.WEAKPOINTS, NETWORK.FLOW.

Open Graph, OpenBI's graph library, does the work: edge_betweenness_cutoff, edge_betweenness, bridges, biconnected_components. See the OAX network functions and Open Graph.

Last updated · OpenBI Studio 0.3.78