Skip to content

Commit

Permalink
Merge pull request #154 from GiulioRossetti/seir/s/d
Browse files Browse the repository at this point in the history
⬆️ add UTLDR to master
  • Loading branch information
GiulioRossetti committed Apr 29, 2020
2 parents c1a81b1 + f8f6d95 commit 450216a
Show file tree
Hide file tree
Showing 8 changed files with 754 additions and 26 deletions.
3 changes: 2 additions & 1 deletion ndlib/models/DiffusionModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import future.utils
import six
from netdispatch import AGraph
import tqdm

__author__ = "Giulio Rossetti"
__license__ = "BSD-2-Clause"
Expand Down Expand Up @@ -196,7 +197,7 @@ def iteration_bunch(self, bunch_size, node_status=True):
:return: a list containing for each iteration a dictionary {"iteration": iteration_id, "status": dictionary_node_to_status}
"""
system_status = []
for it in past.builtins.xrange(0, bunch_size):
for it in tqdm.tqdm(past.builtins.xrange(0, bunch_size)):
its = self.iteration(node_status)
system_status.append(its)
return system_status
Expand Down
20 changes: 12 additions & 8 deletions ndlib/models/epidemics/KerteszThresholdModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,18 @@ def iteration(self, node_status=True):
i = 0
while i < number_node_blocked:
# select a random node
node = list(self.graph.nodes())[np.random.randint(0, self.graph.number_of_nodes())]

# node not infected
if actual_status[node] == 0:

# node blocked
actual_status[node] = -1
self.status[node] = -1
#print("aa", len(self.graph.nodes()))#, self.graph.number_of_nodes(), np.random.randint(0, self.graph.number_of_nodes()))
try:
node = list(self.graph.nodes())[np.random.randint(0, self.graph.number_of_nodes())]

# node not infected
if actual_status[node] == 0:

# node blocked
actual_status[node] = -1
self.status[node] = -1
i += 1
except:
i += 1

self.actual_iteration += 1
Expand Down
Loading

0 comments on commit 450216a

Please sign in to comment.