OpenBI Docs Buy

NETWORK.COMMUNITIES OpenBI

Communities of nodes (Louvain, Leiden, Walktrap and others), with their modularity.

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

Syntax

NETWORK.COMMUNITIES ( <links>, <from>, <to> [, <weight>] [, <method>] [, <resolution>] )
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.
methodText
optional
How the communities are found: "louvain" (when left out), "leiden", "infomap", "walktrap", "fastgreedy", "edgebetweenness" or "labelprop".
resolutionNumber
optional
For Louvain and Leiden: above 1 for more, smaller communities, below 1 for fewer, larger ones. 1 when left out.

Returns

Table. A row a node, with the columns Node, Community, Size (the nodes in its community) and Modularity.

Remarks

  • The links are taken both ways, with their weights.
  • Communities are numbered from 1, the largest; between two of the same size, the one with the node that comes first in the nodes' order.
  • Modularity measures how much more the nodes link inside their communities than chance would have them, for the whole split (at resolution 1), so it is the same on every row: above 0.3 is a clear structure.
  • The same rows always give the same communities: the random choices some methods make are fixed.
  • The rows come out in the order of the nodes' values: numbers from the smallest, then text by character code with capitals read as small letters (A and a together, Ä after z), then dates, then FALSE and TRUE. Rows that come in another order give the same result, communities and ties included; up to 0.3.76 the order the rows came in could change them.
  • Edge betweenness is slow: it takes networks of up to 5,000 links. Louvain and Leiden suit large networks.
  • A network without links gives every node a community of its own.
  • 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.

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

Two groups of friends

The four around Di and Fay, and the triangle of Ann, Bo and Cy.

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.COMMUNITIES ( Links, [From], [To] )
NodeCommunitySizeModularity
Ann230.3671875
Bo230.3671875
Cy230.3671875
Di140.3671875
Ed140.3671875
Fay140.3671875
Gus140.3671875

A higher resolution

At resolution 3, Louvain cuts the network into smaller pieces, at a lower modularity.

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.COMMUNITIES ( Links, [From], [To], , "louvain", 3 )
NodeCommunitySizeModularity
Ann120.0390625
Bo120.0390625
Cy310.0390625
Di410.0390625
Ed510.0390625
Fay220.0390625
Gus220.0390625

Neighbourhoods of the town

The places linked by a drive of eight minutes or less fall into three neighbourhoods.

EVALUATE
NETWORK.COMMUNITIES ( FILTER ( Distances, Distances[Minutes] <= 8 ), Distances[From], Distances[To] )
ORDER BY [Community], [Node]
NodeCommunitySizeModularity
Depot Alnabru170.416428571428571
Shop Bjørvika170.416428571428571
Shop Grønland170.416428571428571
Shop Grünerløkka170.416428571428571
Shop Kampen170.416428571428571
Shop Tøyen170.416428571428571
Shop Vålerenga170.416428571428571
Shop Nydalen260.416428571428571
Shop Sagene260.416428571428571
Shop St. Hanshaugen260.416428571428571
Shop Storo260.416428571428571
Shop Torshov260.416428571428571
Shop Ullevål260.416428571428571
Shop Frogner330.416428571428571
Shop Majorstuen330.416428571428571
Shop Skøyen330.416428571428571

NETWORK.NODES, NETWORK.GRAPH, NETWORK.CLIQUES, NETWORK.EMBED.

Open Graph, OpenBI's graph library, does the work: community_multilevel, strength, community_leiden, community_walktrap, community_fastgreedy, community_label_propagation, community_infomap, community_edge_betweenness, modularity. See the OAX network functions and Open Graph.

Last updated · OpenBI Studio 0.3.78