egttools.plotting.indicators.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_toleranceof 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 strategyjfixates in a population of strategyi(as returned bycalculate_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 thefrequencyof 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 as1.00as drift.min_frequency (
float) – Strategies whose stationary frequency is below this value are left out.
- Returns:
Nodes are strategy indices with attributes
labelandfrequency. Edges have attributesratio(\(r_{ij}\)) andkind("selection"or"drift").graph.graphstorespopulation_sizeanddrift_tolerance.- Return type: