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 is2·e / (k·(k−1))whereeis the number of edges among its neighbours; nodes withk < 2contribute0. The result is the mean over all nodes, in[0, 1].0.0forn = 0. - average_
path_ length - The average shortest-path length over all ordered pairs of distinct, connected
nodes (undirected).
0.0when 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).
0for 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.0when there are no triads.