aboutsummaryrefslogtreecommitdiffstats
path: root/simulation/main.py
diff options
context:
space:
mode:
authorjeanpouget-abadie <jean.pougetabadie@gmail.com>2015-11-29 18:50:34 -0500
committerjeanpouget-abadie <jean.pougetabadie@gmail.com>2015-11-29 18:50:34 -0500
commit582ea9dade68859e3d863d80a3aeddcb10a4c368 (patch)
treeaf8e010329d9f31a220ba8ffc765f686c769ed37 /simulation/main.py
parent7322c00eafcde38dadbf9d4f05a1572d627355bf (diff)
downloadcascades-582ea9dade68859e3d863d80a3aeddcb10a4c368.tar.gz
simple heuristic + star graph + rmse computation
Diffstat (limited to 'simulation/main.py')
-rw-r--r--simulation/main.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/simulation/main.py b/simulation/main.py
index a916034..81133c7 100644
--- a/simulation/main.py
+++ b/simulation/main.py
@@ -19,6 +19,16 @@ def create_random_graph(n_nodes, p=.5):
return np.log(1. / (1 - p * graph))
+def create_star(n_nodes, p=.5):
+ graph = np.zeros((n_nodes, n_nodes))
+ graph[0] = np.ones((n_nodes,))
+ graph[0, 0] = 0
+ for index, row in enumerate(graph[1:-1]):
+ row[index + 1] = 1
+ graph[-1, 1] = 1
+ return np.log(1. / (1 - p * graph))
+
+
def simulate_cascade(x, graph):
"""
Simulate an IC cascade given a graph and initial state.