hypercontagion.sim.functions
Provides predefined contagion functions for use in the hypercontagion library.
Functions
- hypercontagion.sim.functions.collective_contagion(node, status, edge)[source]
Collective contagion function.
- Parameters
node (hashable) – node ID
status (dict) – keys are node IDs and values are their statuses.
edge (iterable) – hyperedge
- Returns
0 if no transmission can occur, 1 if it can.
- Return type
int
- hypercontagion.sim.functions.individual_contagion(node, status, edge)[source]
Individual contagion function.
- Parameters
node (hashable) – node ID
status (dict) – keys are node IDs and values are their statuses.
edge (iterable) – hyperedge
- Returns
0 if no transmission can occur, 1 if it can.
- Return type
int
- hypercontagion.sim.functions.threshold(node, status, edge, threshold=0.5)[source]
Threshold contagion process.
Contagion may spread if greater than a specified fraction of hyperedge neighbors are infected.
- Parameters
node (hashable) – node ID
status (dict) – keys are node IDs and values are their statuses.
edge (iterable of hashables) – nodes in the hyperedge
threshold (float, default: 0.5) – the critical fraction of hyperedge neighbors above which contagion spreads.
- Returns
0 if no transmission can occur, 1 if it can.
- Return type
int
- hypercontagion.sim.functions.majority_vote(node, status, edge)[source]
Majority vote contagion process.
Contagion may spread if the majority of a node’s hyperedge neighbors are infected. If it’s a tie, the result is random.
- Parameters
node (hashable) – node ID
status (dict) – keys are node IDs and values are their statuses.
edge (iterable of hashables) – nodes in the hyperedge
- Returns
0 if no transmission can occur, 1 if it can.
- Return type
int