egttools.plotting.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 (ndarray) – 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 (Optional[Sequence[str]])

  • strategy_colors (Optional[Sequence])

  • layout (Optional[Dict]) – {node: (x, y)}. Computed once via spring layout if omitted.

  • interval_ms (int) – Milliseconds between frames.

  • node_size (int)

  • save_path (Optional[str]) – If given, save the animation to this path. Extension determines format: .gif uses Pillow; .mp4 uses ffmpeg.

  • fps (int) – Frames per second (only used when saving).

Return type:

matplotlib.animation.FuncAnimation