Skip to main content

Module stats

Module stats 

Source
Expand description

Whole-graph statistics — the scalar summaries a stats panel shows, computed on the undirected view: the clustering coefficient (how tightly neighbourhoods close into triangles) and the diameter / average path length (the graph’s reach). These fill the two gaps the rest of super left open.

All are undirected + deterministic (BFS-based, O(n·(n+m)) for the distance measures — fine for the interactive graphs a navigator holds).

Functions§

average_clustering
The average local clustering coefficient (Watts–Strogatz). For each node with undirected degree k ≥ 2, the local coefficient is 2·e / (k·(k−1)) where e is the number of edges among its neighbours; nodes with k < 2 contribute 0. The result is the mean over all nodes, in [0, 1]. 0.0 for n = 0.
average_path_length
The average shortest-path length over all ordered pairs of distinct, connected nodes (undirected). 0.0 when no pair is connected.
diameter
The diameter — the longest shortest path (in hops) between any two connected nodes (undirected). A disconnected graph reports the max over its components (∞ pairs are ignored). 0 for a graph with no edges.
transitivity
The global clustering coefficient (transitivity) = 3·triangles / triads, where a triad is a connected path of two edges (a node with an ordered pair of neighbours). 0.0 when there are no triads.