aryagraph.sim.random_walk#
- aryagraph.sim.random_walk(g: Any, *, walkers: int = 1, steps: int = 100, start: Any = None, restart: float = 0.0, weight: str | Callable[[Hashable, Hashable, dict], float] | None = None, seed: int | Generator | None = None, n_frames: int | None = None) SimulationResult[source]#
Simulate independent random walkers.
- Parameters:
walkers, steps – Number of walkers and of steps each takes.
start –
None(each walker starts at a uniformly random node), one node for all walkers, or a sequence ofwalkersnodes.restart – Probability, at each step, of jumping back to the walker’s own start node instead of moving (random walk with restart).
weight – Edge weights for the transition probabilities (
None: all 1).n_frames – Keep only about this many evenly spaced frames (default: every step); trajectories are always complete.
- Returns:
SimulationResult – Categorical states
unvisited/visited/current(a node holding at least one walker).edge_activitylists the moves along edges (teleports and restarts are not edges).meta["trajectories"]is a(walkers, steps + 1)array of node indices intoresult.nodes;meta["visits"]the share of all walker positions (start included) spent at each node, which converges tostationary_distribution()whenrestart == 0(for an undirected connected graph,deg / 2m).