From 582ea9dade68859e3d863d80a3aeddcb10a4c368 Mon Sep 17 00:00:00 2001 From: jeanpouget-abadie Date: Sun, 29 Nov 2015 18:50:34 -0500 Subject: simple heuristic + star graph + rmse computation --- simulation/main.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'simulation/main.py') 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. -- cgit v1.2.3-70-g09d2