aboutsummaryrefslogtreecommitdiffstats
path: root/jpa_test/cascade_creation.py
diff options
context:
space:
mode:
authorJean Pouget-Abadie <jean.pougetabadie@gmail.com>2014-11-28 15:50:20 -0500
committerJean Pouget-Abadie <jean.pougetabadie@gmail.com>2014-11-28 15:50:20 -0500
commit4fec932bbdbb17b490f8c49a8e927d55b127b8c5 (patch)
tree5456b9277c4ff0822ef312d814789380f716718f /jpa_test/cascade_creation.py
parent68ff5bda1771031d0ac271027cb6245272046a94 (diff)
parentfb677abac04ddc697aa19109cef85c18c0f133ff (diff)
downloadcascades-4fec932bbdbb17b490f8c49a8e927d55b127b8c5.tar.gz
Merge pull request #1 from ericbalkanski/master
Stanford Network
Diffstat (limited to 'jpa_test/cascade_creation.py')
-rw-r--r--jpa_test/cascade_creation.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/jpa_test/cascade_creation.py b/jpa_test/cascade_creation.py
index f8defc7..c5d33cc 100644
--- a/jpa_test/cascade_creation.py
+++ b/jpa_test/cascade_creation.py
@@ -14,6 +14,25 @@ class InfluenceGraph(nx.Graph):
self.add_nodes_from(G.nodes())
self.add_edges_from(G.edges())
+ def createStanfordGraph(self, file):
+ """
+ Takes a file from the Stanford collection of networks
+ Need to remove comments on top of the file
+ Graph still needs to be weighted on the edges
+ """
+ f = open(file, 'r')
+ data = f.readlines()
+ G = nx.DiGraph()
+ for edge in data:
+ split1 = edge.split('\t')
+ split2 = split1[1].split('\n')
+
+ u = int(split1[0])
+ v = int(split2[0])
+ G.add_edge(u,v)
+ self.add_nodes_from(G.nodes())
+ self.add_edges_from(G.edges())
+
@property
def mat(self):
if not hasattr(self, '_mat'):
@@ -47,11 +66,6 @@ def icc_cascade(G, p_init):
return cascade
-def concat_cascades(cascades):
- """
- Concatenate list of cascades into matrix
- """
-
def test():
"""