Models
cynetdiff.models
¶
DiffusionModel
¶
Base class for Diffusion Models. This class provides an interface for advancing, resetting, and retrieving newly activated nodes. Nodes for the graph of the diffusion process have labels in [0, n-1] and the graph is represented in compressed sparse row format.
advance_model()
method descriptor
¶
Advances the diffusion model by one step.
advance_until_completion()
method descriptor
¶
Continuously advances the model until the diffusion process is complete.
get_activated_nodes()
method descriptor
¶
Yields all activated nodes.
Yields:
Type | Description |
---|---|
int
|
All of the currently activated nodes. |
get_newly_activated_nodes()
method descriptor
¶
A generator yielding the nodes that were newly activated in the last iteration of the model.
Yields:
Type | Description |
---|---|
int
|
The label of a node that was newly activated. |
get_num_activated_nodes()
¶
Returns the total number of activated nodes in the model.
Returns:
Type | Description |
---|---|
int
|
Total number of activated nodes. |
reset_model()
method descriptor
¶
Resets the model to the original set of seed nodes. This is useful if running many simulations over the same original seed set.
set_seeds(seeds)
¶
Sets the initial active nodes (seeds) for the diffusion process. Must be valid nodes in the graph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seeds |
Iterable[int]
|
Seeds to set as initially active. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If a node in the seed set is invalid (not in the graph). |
IndependentCascadeModel
¶
Bases: cynetdiff.models.DiffusionModel
A Diffusion Model representing the Independent Cascade process. This class is a subclass of the DiffusionModel and provides specific implementations for the Independent Cascade diffusion process.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
starts |
array
|
An array of start indices for each node's edges in the edge array. Type
of array elements must be |
required |
edges |
array
|
An array of edges represented as integer indices of nodes. Type
of array elements must be |
required |
activation_prob |
float
|
Uniform activation probability for the Independent Cascade model.
Defaults to |
0.1
|
activation_probs |
array
|
Set individual activation probabilities for the Independent Cascade model.
Overrides |
None
|
_edge_probabilities |
array
|
An array of success probabilities for each edge, default is None. |
None
|
LinearThresholdModel
¶
Bases: cynetdiff.models.DiffusionModel
A Diffusion Model representing the Linear Threshold process. This class is a subclass of the DiffusionModel and provides specific implementations for the Linear Threshold diffusion process.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
starts |
array
|
An array of start indices for each node's edges in the edge array. Type
of array elements must be |
required |
edges |
array
|
An array of edges represented as integer indices of nodes. Type
of array elements must be |
required |
influence |
array
|
An array of influence values for each edge. Array elements must be
|
None
|