aboutsummaryrefslogtreecommitdiffstats
path: root/jpa_test/algorithms.py
diff options
context:
space:
mode:
authorjeanpouget-abadie <jean.pougetabadie@gmail.com>2014-11-29 13:38:11 -0500
committerjeanpouget-abadie <jean.pougetabadie@gmail.com>2014-11-29 13:38:11 -0500
commit59add61ec7b8ada40909edddfb88f193e489303a (patch)
treed45b56299916ab8249e0222afb112aa5e2191aa1 /jpa_test/algorithms.py
parentaf767b2dcba2d67cd08a5aac4bc4b926d0129382 (diff)
downloadcascades-59add61ec7b8ada40909edddfb88f193e489303a.tar.gz
algorithms.py
Diffstat (limited to 'jpa_test/algorithms.py')
-rw-r--r--jpa_test/algorithms.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/jpa_test/algorithms.py b/jpa_test/algorithms.py
new file mode 100644
index 0000000..2ee08ec
--- /dev/null
+++ b/jpa_test/algorithms.py
@@ -0,0 +1,32 @@
+import numpy as np
+import networkx as nx
+import cascade_creation
+
+
+def greedy_prediction(G, cascades):
+ """
+ returns estimated graph
+ """
+ G_hat = cascade_creation.InfluenceGraph(max_proba=None)
+ G.add_nodes_from(G.nodes())
+ for node in G.nodes():
+ unaccounted = cascades
+ for cascade in cascades:
+ time_step = 0
+ while not cascade[time_step][node]:
+ time_step += 1
+
+def test():
+ """
+ unit test
+ """
+ G = cascade_creation.InfluenceGraph(max_proba = .3)
+ G.erdos_init(n = 100, p = 1)
+ import time
+ t0 = time.time()
+ print len(cascade_creation.icc_cascade(G, p_init=.1))
+ t1 = time.time()
+ print t1 - t0
+
+if __name__=="__main__":
+ test()