Skip to content

Commit 51dccbb

Browse files
committed
fix ICE and ICEP Model and add docs for ICE, ICP and ICEP model
1 parent 60629a3 commit 51dccbb

File tree

6 files changed

+387
-10
lines changed

6 files changed

+387
-10
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
**************************************************
2+
Independent Cascades with Community Embeddedness
3+
**************************************************
4+
5+
The Independent Cascades with Community Embeddedness model was introduced by Milli and Rossetti in 2019 [#]_.
6+
7+
This model is a variation of the well-known Independent Cascade (IC), and it is designed to embed community awareness into the IC model.
8+
The probability p(u,v) of the IC model is replaced by the edge embeddedness.
9+
10+
The embeddedness of an edge :math:`(u,v)` with :math:`u,v \in C` is defined as:
11+
:math:`e_{u,v} = \frac{\phi_{u,v}}{|\Gamma(u) \cup \Gamma(v)|}`
12+
where :math:`\phi_{u,v}` is the number of common neighbors of u and v within :math:`C`, and :math:`\Gamma(u)` ( :math:`\Gamma(v)`) is the set of neighbors of the node u (v) in the analyzed graph G.
13+
14+
The ICE model starts with an initial set of **active** nodes A0; the diffusive process unfolds in discrete steps according to the following randomized rule:
15+
16+
- When node v becomes active in step t, it is given a single chance to activate each currently inactive neighbor u. If v and u belong to the same community, it succeeds with a probability :math:`e_{u,v}`; otherwise with probability :math:`\min\{e_{z,v}|(z, v)\in E\}`.
17+
- If u has multiple newly activated neighbors, their attempts are sequenced in an arbitrary order.
18+
- If v succeeds, then u will become active in step t + 1; but whether or not v succeeds, it cannot make any further attempts to activate u in subsequent rounds.
19+
- The process runs until no more activations are possible.
20+
21+
--------
22+
Statuses
23+
--------
24+
25+
During the simulation a node can experience the following statuses:
26+
27+
=========== ====
28+
Name Code
29+
=========== ====
30+
Susceptible 0
31+
Infected 1
32+
Removed 2
33+
=========== ====
34+
35+
36+
----------
37+
Parameters
38+
----------
39+
40+
The model is parameter free
41+
42+
The initial infection status can be defined via:
43+
44+
- **fraction_infected**: Model Parameter, float in [0, 1]
45+
- **Infected**: Status Parameter, set of nodes
46+
47+
The two options are mutually exclusive and the latter takes precedence over the former.
48+
49+
-------
50+
Methods
51+
-------
52+
53+
The following class methods are made available to configure, describe and execute the simulation:
54+
55+
^^^^^^^^^
56+
Configure
57+
^^^^^^^^^
58+
59+
.. autoclass:: ndlib.models.epidemics.ICEModel.ICEModel
60+
.. automethod:: ndlib.models.epidemics.ICEModel.ICEModel.__init__(graph)
61+
62+
.. automethod:: ndlib.models.epidemics.ICEModel.ICEModel.set_initial_status(self, configuration)
63+
.. automethod:: ndlib.models.epidemics.ICEModel.ICEModel.reset(self)
64+
65+
^^^^^^^^
66+
Describe
67+
^^^^^^^^
68+
69+
.. automethod:: ndlib.models.epidemics.ICEModel.ICEModel.get_info(self)
70+
.. automethod:: ndlib.models.epidemics.ICEModel.ICEModel.get_status_map(self)
71+
72+
^^^^^^^^^^^^^^^^^^
73+
Execute Simulation
74+
^^^^^^^^^^^^^^^^^^
75+
.. automethod:: ndlib.models.epidemics.ICEModel.ICEModel.iteration(self)
76+
.. automethod:: ndlib.models.epidemics.ICEModel.ICEModel.iteration_bunch(self, bunch_size)
77+
78+
-------
79+
Example
80+
-------
81+
82+
In the code below is shown an example of instantiation and execution of an ICE model simulation on a random graph: we set the initial set of infected nodes as 1% of the overall population.
83+
84+
85+
.. code-block:: python
86+
87+
import networkx as nx
88+
import ndlib.models.ModelConfig as mc
89+
import ndlib.models.epidemics as ep
90+
91+
# Network topology
92+
g = nx.erdos_renyi_graph(1000, 0.1)
93+
94+
# Model selection
95+
model = ep.ICEModel(g)
96+
97+
# Model Configuration
98+
config = mc.Configuration()
99+
config.add_model_parameter('fraction_infected', 0.1)
100+
101+
model.set_initial_status(config)
102+
103+
# Simulation execution
104+
iterations = model.iteration_bunch(200)
105+
106+
107+
.. [#] L. Milli and G. Rossetti. “Community-Aware Content Diffusion: Embeddednes and Permeability,” in Proceedings of International Conference on Complex Networks and Their Applications, 2019 pp. 362--371.
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
******************************************************************
2+
Independent Cascades with Community Embeddedness and Permeability
3+
******************************************************************
4+
5+
The Independent Cascades with Community Embeddedness and Permeability model was introduced by Milli and Rossetti in 2020 [#]_.
6+
7+
This model is a combination of ICE and ICP methods.
8+
9+
The ICEP model starts with an initial set of **active** nodes A0; the diffusive process unfolds in discrete steps according to the following randomized rule:
10+
11+
- When node v becomes active in step t, it is given a single chance to activate each currently inactive neighbor u. If v and u belong to the same community, the method acts as the ICE model, otherwise as the ICP model.
12+
- If u has multiple newly activated neighbors, their attempts are sequenced in an arbitrary order.
13+
- If v succeeds, then u will become active in step t + 1; but whether or not v succeeds, it cannot make any further attempts to activate u in subsequent rounds.
14+
- The process runs until no more activations are possible.
15+
16+
--------
17+
Statuses
18+
--------
19+
20+
During the simulation a node can experience the following statuses:
21+
22+
=========== ====
23+
Name Code
24+
=========== ====
25+
Susceptible 0
26+
Infected 1
27+
Removed 2
28+
=========== ====
29+
30+
31+
----------
32+
Parameters
33+
----------
34+
35+
====================== ===== =============== ======= ========= ======================
36+
Name Type Value Type Default Mandatory Description
37+
====================== ===== =============== ======= ========= ======================
38+
Edge threshold Edge float in [0, 1] 0.1 False Edge threshold
39+
Community permeability Model float in [0, 1] 0.5 True Community Permeability
40+
====================== ===== =============== ======= ========= ======================
41+
42+
The initial infection status can be defined via:
43+
44+
- **fraction_infected**: Model Parameter, float in [0, 1]
45+
- **Infected**: Status Parameter, set of nodes
46+
47+
The two options are mutually exclusive and the latter takes precedence over the former.
48+
49+
-------
50+
Methods
51+
-------
52+
53+
The following class methods are made available to configure, describe and execute the simulation:
54+
55+
^^^^^^^^^
56+
Configure
57+
^^^^^^^^^
58+
59+
.. autoclass:: ndlib.models.epidemics.ICEPModel.ICEPModel
60+
.. automethod:: ndlib.models.epidemics.ICEPModel.ICEPModel.__init__(graph)
61+
62+
.. automethod:: ndlib.models.epidemics.ICEPModel.ICEPModel.set_initial_status(self, configuration)
63+
.. automethod:: ndlib.models.epidemics.ICEPModel.ICEPModel.reset(self)
64+
65+
^^^^^^^^
66+
Describe
67+
^^^^^^^^
68+
69+
.. automethod:: ndlib.models.epidemics.ICEPModel.ICEPModel.get_info(self)
70+
.. automethod:: ndlib.models.epidemics.ICEPModel.ICEPModel.get_status_map(self)
71+
72+
^^^^^^^^^^^^^^^^^^
73+
Execute Simulation
74+
^^^^^^^^^^^^^^^^^^
75+
.. automethod:: ndlib.models.epidemics.ICEPModel.ICEPModel.iteration(self)
76+
.. automethod:: ndlib.models.epidemics.ICEPModel.ICEPModel.iteration_bunch(self, bunch_size)
77+
78+
-------
79+
Example
80+
-------
81+
82+
In the code below is shown an example of instantiation and execution of an ICEP model simulation on a random graph: we set the initial set of infected nodes as 1% of the overall population, assign a threshold of 0.1 to all the edges and set the community permeability equal 0.3.
83+
84+
85+
.. code-block:: python
86+
87+
import networkx as nx
88+
import ndlib.models.ModelConfig as mc
89+
import ndlib.models.epidemics as ep
90+
91+
# Network topology
92+
g = nx.erdos_renyi_graph(1000, 0.1)
93+
94+
# Model selection
95+
model = ep.ICEPModel(g)
96+
97+
# Model Configuration
98+
config = mc.Configuration()
99+
config.add_model_parameter('fraction_infected', 0.1)
100+
config.add_model_parameter('permeability', 0.3)
101+
102+
103+
# Setting the edge parameters
104+
threshold = 0.1
105+
for e in g.edges():
106+
config.add_edge_configuration("threshold", e, threshold)
107+
108+
model.set_initial_status(config)
109+
110+
# Simulation execution
111+
iterations = model.iteration_bunch(200)
112+
113+
114+
.. [#] L. Milli and G. Rossetti. “Barriers or Accelerators? Modeling the two-foldnature of meso-scale network topologies indiffusive phenomena,” 2020
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
**************************************************
2+
Independent Cascades with Community Permeability
3+
**************************************************
4+
5+
The Independent Cascades with Community Permeability model was introduced by Milli and Rossetti in 2019 [#]_.
6+
7+
This model is a variation of the well-known Independent Cascade (IC), and it is designed to embed community awareness into the IC model.
8+
This model exploits the idea of permeability. A community is “permeable” to a given content if it permits that content to spread from it fast
9+
(or vice-versa, if it permits the content to be easily received from nodes outside the community). Conversely, a community has a low degree of permeability if it dampens the diffusion probability across its border.
10+
11+
The ICP model starts with an initial set of **active** nodes A0; the diffusive process unfolds in discrete steps according to the following randomized rule:
12+
13+
- When node v becomes active in step t, it is given a single chance to activate each currently inactive neighbor u. If v and u belong to the same community, the method works as a standard IC model (it succeeds with a probability p(v,u)); instead, if the nodes are part of to different communities, the likelihood p(v,u) is dampened of a factor :math:`\eta` (the community permeability parameter).
14+
- If u has multiple newly activated neighbors, their attempts are sequenced in an arbitrary order.
15+
- If v succeeds, then u will become active in step t + 1; but whether or not v succeeds, it cannot make any further attempts to activate u in subsequent rounds.
16+
- The process runs until no more activations are possible.
17+
18+
--------
19+
Statuses
20+
--------
21+
22+
During the simulation a node can experience the following statuses:
23+
24+
=========== ====
25+
Name Code
26+
=========== ====
27+
Susceptible 0
28+
Infected 1
29+
Removed 2
30+
=========== ====
31+
32+
33+
----------
34+
Parameters
35+
----------
36+
37+
====================== ===== =============== ======= ========= ======================
38+
Name Type Value Type Default Mandatory Description
39+
====================== ===== =============== ======= ========= ======================
40+
Edge threshold Edge float in [0, 1] 0.1 False Edge threshold
41+
Community permeability Model float in [0, 1] 0.5 True Community Permeability
42+
====================== ===== =============== ======= ========= ======================
43+
44+
The initial infection status can be defined via:
45+
46+
- **fraction_infected**: Model Parameter, float in [0, 1]
47+
- **Infected**: Status Parameter, set of nodes
48+
49+
The two options are mutually exclusive and the latter takes precedence over the former.
50+
51+
-------
52+
Methods
53+
-------
54+
55+
The following class methods are made available to configure, describe and execute the simulation:
56+
57+
^^^^^^^^^
58+
Configure
59+
^^^^^^^^^
60+
61+
.. autoclass:: ndlib.models.epidemics.ICPModel.IndependentCascadesModel
62+
.. automethod:: ndlib.models.epidemics.ICPModel.ICPModel.__init__(graph)
63+
64+
.. automethod:: ndlib.models.epidemics.ICPModel.ICPModel.set_initial_status(self, configuration)
65+
.. automethod:: ndlib.models.epidemics.ICPModel.ICPModel.reset(self)
66+
67+
^^^^^^^^
68+
Describe
69+
^^^^^^^^
70+
71+
.. automethod:: ndlib.models.epidemics.ICPModel.ICPModel.get_info(self)
72+
.. automethod:: ndlib.models.epidemics.ICPModel.ICPModel.get_status_map(self)
73+
74+
^^^^^^^^^^^^^^^^^^
75+
Execute Simulation
76+
^^^^^^^^^^^^^^^^^^
77+
.. automethod:: ndlib.models.epidemics.ICPModel.ICPModel.iteration(self)
78+
.. automethod:: ndlib.models.epidemics.ICPModel.ICPModel.iteration_bunch(self, bunch_size)
79+
80+
-------
81+
Example
82+
-------
83+
84+
In the code below is shown an example of instantiation and execution of an ICP model simulation on a random graph: we set the initial set of infected nodes as 1% of the overall population, assign a threshold of 0.1 to all the edges and set the community permeability equal 0.3.
85+
86+
87+
.. code-block:: python
88+
89+
import networkx as nx
90+
import ndlib.models.ModelConfig as mc
91+
import ndlib.models.epidemics as ep
92+
93+
# Network topology
94+
g = nx.erdos_renyi_graph(1000, 0.1)
95+
96+
# Model selection
97+
model = ep.ICPModel(g)
98+
99+
# Model Configuration
100+
config = mc.Configuration()
101+
config.add_model_parameter('fraction_infected', 0.1)
102+
config.add_model_parameter('permeability', 0.3)
103+
104+
105+
# Setting the edge parameters
106+
threshold = 0.1
107+
for e in g.edges():
108+
config.add_edge_configuration("threshold", e, threshold)
109+
110+
model.set_initial_status(config)
111+
112+
# Simulation execution
113+
iterations = model.iteration_bunch(200)
114+
115+
116+
.. [#] L. Milli and G. Rossetti. “Community-Aware Content Diffusion: Embeddednes and Permeability,” in Proceedings of International Conference on Complex Networks and Their Applications, 2019 pp. 362--371.

docs/reference/reference.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ In ``NDlib`` are implemented the following **Epidemic** models:
5050
models/epidemics/Profile.rst
5151
models/epidemics/ProfileThreshold.rst
5252
models/epidemics/UTLDR.rst
53+
models/epidemics/ICEP.rst
54+
models/epidemics/ICP.rst
55+
models/epidemics/ICE.rst
5356

5457

5558
----------------

0 commit comments

Comments
 (0)