NETWORK.GRAPH OpenBI
The whole network's measures in one row: size, density, components, diameter, modularity and more.
Group: Networks. OpenBI’s own: DAX has no function of this name.
Syntax
NETWORK.GRAPH ( <links>, <from>, <to> [, <weight>] [, <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. |
weight | Expression 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. |
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. One row. Its columns: Nodes and Edges; Density; Components and Largest component; Transitivity and Average clustering; Assortativity; Diameter and Average path length; Modularity; and Reciprocity.
Remarks
- Density is the share of all possible links that are there. Components counts the connected parts, and Largest component the nodes in the biggest one.
- Transitivity is the share of connected triples that close into a triangle. Average clustering is the mean of each node's clustering, leaving out nodes with fewer than two neighbours, so it can differ from the mean of the Clustering column of
NETWORK.CENTRALITY. - Assortativity is above 0 when nodes with many links link to each other, below 0 when they link to nodes with few.
- Diameter is the longest of the shortest paths, in hops, and Average path length the mean of them, both over the pairs that can reach each other. On a very large network (nodes times links above four billion) both are blank.
- Modularity is that of the Louvain communities
NETWORK.COMMUNITIESfinds, with the weights. Reciprocity, for a directed network only, is the share of links that are answered by one the other way. - 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.
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
Seven friends
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
SELECTCOLUMNS (
NETWORK.GRAPH ( Links, [From], [To] ),
"Nodes", [Nodes],
"Edges", [Edges],
"Density", [Density],
"Diameter", [Diameter],
"Average path length", [Average path length],
"Transitivity", [Transitivity],
"Average clustering", [Average clustering],
"Modularity", [Modularity]
)
| Nodes | Edges | Density | Diameter | Average path length | Transitivity | Average clustering | Modularity |
|---|---|---|---|---|---|---|---|
| 7 | 8 | 0.380952380952381 | 4 | 2.04761904761905 | 0.5 | 0.666666666666667 | 0.3671875 |
Payments, one way
No payment is answered by one back, so the reciprocity is 0.
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
SELECTCOLUMNS (
NETWORK.GRAPH ( Payments, [Payer], [Payee], [Amount], TRUE ),
"Nodes", [Nodes],
"Edges", [Edges],
"Density", [Density],
"Components", [Components],
"Reciprocity", [Reciprocity],
"Assortativity", [Assortativity]
)
| Nodes | Edges | Density | Components | Reciprocity | Assortativity |
|---|---|---|---|---|---|
| 6 | 7 | 0.233333333333333 | 1 | 0 | -0.0912870929175273 |
Related functions
NETWORK.NODES, NETWORK.CENTRALITY, NETWORK.COMMUNITIES, NETWORK.TRIADS.
Open Graph, OpenBI's graph library, does the work: density, connected_components, transitivity_undirected, transitivity_avglocal_undirected, assortativity_degree, diameter, average_path_length, community_multilevel, modularity, reciprocity. See the OAX network functions and Open Graph.