diff options
| author | jeanpouget-abadie <jean.pougetabadie@gmail.com> | 2014-11-28 15:53:50 -0500 |
|---|---|---|
| committer | jeanpouget-abadie <jean.pougetabadie@gmail.com> | 2014-11-28 15:53:50 -0500 |
| commit | af767b2dcba2d67cd08a5aac4bc4b926d0129382 (patch) | |
| tree | b30649d01dfdc352ac3275db7c506074a0f5a5fc /jpa_test/cascade_creation.py | |
| parent | 4a4a286746568299e240d524a9c9860822141781 (diff) | |
| parent | 4fec932bbdbb17b490f8c49a8e927d55b127b8c5 (diff) | |
| download | cascades-af767b2dcba2d67cd08a5aac4bc4b926d0129382.tar.gz | |
Merge branch 'master' of https://github.com/jeanpouget-abadie/cracking_cascades
Conflicts:
jpa_test/cascade_creation.py
Diffstat (limited to 'jpa_test/cascade_creation.py')
| -rw-r--r-- | jpa_test/cascade_creation.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/jpa_test/cascade_creation.py b/jpa_test/cascade_creation.py index ca48431..6e5c34e 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'): |
