Datalens.ai
← All algorithms

GRAPH-COMMUNITIES

square_clustering

Compute the squares clustering coefficient for nodes.

Example of usage

Identify collaboration structure with square_clustering 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)

# 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"]}

# Count four-cycle motifs around individual employees.
result = nx.square_clustering(G)
assert set(result) == set(G) and all(0 <= score <= 1 for score in result.values())

# Assertions above validate this graph result.
print("Expected output verified")