egttools.plotting.network_plots.animate_network_evolution¶
- animate_network_evolution(G, snapshot_matrix, strategy_names=None, strategy_colors=None, layout=None, interval_ms=200, node_size=80, save_path=None, fps=5)[source]¶
Animate the evolution of a network, colouring nodes by strategy.
- Parameters:
G (networkx.Graph)
snapshot_matrix (numpy.ndarray, shape (nb_snapshots, N)) – Each row is a per-node strategy vector at one snapshot. Produced by
NetworkMCEstimator.run_snapshots(return_full=True)or by accumulating the per-snapshot callback into a 2-D array.strategy_names (sequence of str, optional)
strategy_colors (sequence, optional)
layout (dict, optional) –
{node: (x, y)}. Computed once via spring layout if omitted.interval_ms (int) – Milliseconds between frames.
node_size (int)
save_path (str, optional) – If given, save the animation to this path. Extension determines format:
.gifuses Pillow;.mp4uses ffmpeg.fps (int) – Frames per second (only used when saving).
- Return type:
matplotlib.animation.FuncAnimation