Algorithm
Triangle counting
activeNeeds verification
Counts triangles (3-cliques) per node or in total; the basis of clustering coefficients and a common fraud and spam signal.
Definition
Intuition
Two of my friends who are also friends with each other close a triangle; dense triangle regions indicate cohesive groups.
Complexity
| Time | O(E^{1.5}) with degree ordering |
|---|---|
| Space | O(V + E) |
Python
import networkx as nx
t = nx.triangles(G)
cc = nx.clustering(G)Cypher (Neo4j GDS)
CALL gds.triangleCount.stream('myGraph')
YIELD nodeId, triangleCount RETURN gds.util.asNode(nodeId).name, triangleCountProcedure names and options vary between GDS versions; check the GDS docs for your version.
An interactive step-by-step visualizer for this algorithm is planned for phase 3.
Profile
| Time complexity | O(E^{1.5}) with degree ordering |
|---|---|
| Space complexity | O(V + E) |
Relationships
- Belongs to