egttools.plotting.invasion_graph

invasion_graph(fixation_probabilities, population_size, stationary_distribution=None, labels=None, drift_tolerance=0.005, min_frequency=0.0)[source]

Builds the invasion graph of the small-mutation limit.

Each pair of strategies is classified once, by comparing its fixation probabilities with the neutral fixation probability \(\rho_N = 1/Z\). With \(r_{ij} = \rho_{ij} / \rho_N\), where \(\rho_{ij}\) is the probability that a single mutant of strategy \(j\) takes over a population of strategy \(i\):

  • selection: an edge \(i \to j\) for every direction with \(r_{ij} > 1 + \text{drift\_tolerance}\) (both edges if each strategy invades the other);

  • drift: one undirected edge if neither direction exceeds \(1 + \text{drift\_tolerance}\) and at least one is within drift_tolerance of 1 (neutral or nearly neutral pair);

  • no edge otherwise (neither strategy invades the other).

Parameters:
  • fixation_probabilities (ndarray) – Square matrix whose entry [i, j] is the probability that a single mutant of strategy j fixates in a population of strategy i (as returned by calculate_transition_and_fixation_matrix_sml).

  • population_size (int) – Population size \(Z\); the neutral fixation probability is \(1/Z\).

  • stationary_distribution (Optional[ndarray]) – Stationary distribution over the monomorphic states, stored as the frequency of each node.

  • labels (Optional[Sequence[str]]) – Name of each strategy; defaults to the strategy indices.

  • drift_tolerance (float) – Tolerance on \(r_{ij}\) within which a pair counts as neutral. The default treats every ratio that would be displayed as 1.00 as drift.

  • min_frequency (float) – Strategies whose stationary frequency is below this value are left out.

Returns:

Nodes are strategy indices with attributes label and frequency. Edges have attributes ratio (\(r_{ij}\)) and kind ("selection" or "drift"). graph.graph stores population_size and drift_tolerance.

Return type:

DiGraph