aryagraph.sim.stationary_distribution#
- aryagraph.sim.stationary_distribution(g: Any, weight: str | Callable[[Hashable, Hashable, dict], float] | None = None) NodeMap[source]#
Exact stationary distribution
π = πPof the random walk on g.For an undirected graph without dangling nodes the closed form
π(v) = deg_w(v) / Σ deg_wis used (self-loops counted once, matching the transition probabilities). Otherwise the linear systemπ(P - I) = 0, Σπ = 1is solved directly (O(n³)); it has a unique solution exactly when the walk has a single closed class, as in a strongly connected graph (periodicity does not matter). Nodes outside that class get 0.- Raises:
NotConnected – When the walk has several closed classes (the distribution is not unique).