GRAPH-COMMUNITIES
label_propagation_communities
Generates community sets determined by label propagation.
Example of usage
Identify collaboration structure with label_propagation_communities in a six-person, two-department organization.
Usage / limitations
+Use when: Explore employee collaboration patterns, densely connected teams and cross-team bridging.
−Limitations: Results depend on graph topology, edge completeness and algorithm assumptions; small networks are illustrative.
Mathematical formula
See method documentation: implementation and assumptions vary.
Sample dataShow
{
"variable": "teams",
"domain": "Cross-team collaboration network",
"feature_names": [
"team",
"department"
],
"nodes": [
[
"Ana",
"Design"
],
[
"Ben",
"Design"
],
[
"Cara",
"Design"
],
[
"Dan",
"Engineering"
],
[
"Eva",
"Engineering"
],
[
"Finn",
"Engineering"
]
],
"edges": [
[
"Ana",
"Ben"
],
[
"Ben",
"Cara"
],
[
"Cara",
"Ana"
],
[
"Dan",
"Eva"
],
[
"Eva",
"Finn"
],
[
"Finn",
"Dan"
],
[
"Cara",
"Dan"
]
]
}
Code example (Python)
teams = {'nodes': [['Ana', 'Design'], ['Ben', 'Design'], ['Cara', 'Design'], ['Dan', 'Engineering'], ['Eva', 'Engineering'], ['Finn', 'Engineering']], 'edges': [['Ana', 'Ben'], ['Ben', 'Cara'], ['Cara', 'Ana'], ['Dan', 'Eva'], ['Eva', 'Finn'], ['Finn', 'Dan'], ['Cara', 'Dan']]}
# DataLens.ai example — cross-team collaboration analysis.
# The named teams input is provided by Copy input + code + test.
import networkx as nx
# Convert employee collaboration links into an undirected graph.
G = nx.Graph()
G.add_nodes_from([row[0] for row in teams["nodes"]])
G.add_edges_from(teams["edges"])
# Associate each employee with their declared department.
departments = {name: group for name, group in teams["nodes"]}
# Propagate community labels until clusters stabilise.
result = list(nx.community.label_propagation_communities(G))
assert len(result) >= 1 and set().union(*map(set, result)) == set(G)
# Assertions above validate this graph result.
print("Expected output verified")
# DataLens.ai example — cross-team collaboration analysis.
# The named teams input is provided by Copy input + code + test.
import networkx as nx
# Convert employee collaboration links into an undirected graph.
G = nx.Graph()
G.add_nodes_from([row[0] for row in teams["nodes"]])
G.add_edges_from(teams["edges"])
# Associate each employee with their declared department.
departments = {name: group for name, group in teams["nodes"]}
# Propagate community labels until clusters stabilise.
result = list(nx.community.label_propagation_communities(G))
assert len(result) >= 1 and set().union(*map(set, result)) == set(G)
# Assertions above validate this graph result.
print("Expected output verified")