-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgraph_data.py
More file actions
43 lines (29 loc) · 974 Bytes
/
graph_data.py
File metadata and controls
43 lines (29 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import os
class GraphData:
def __init__(self,path):
data_set_name = os.path.basename(path)
# load edges
f = open(path + "/" + data_set_name + '_multiplex.edges')
lines = f.readlines()
f.close()
edges = [[e[0], e[1], e[2], 1] for e in
[[int(float(c)) - 1 for c in line.split(' ')] for line in lines if len(line) > 6]]
# load info
info_path = path + "/" + data_set_name + '_info.txt'
f = open(info_path)
lines = f.readlines()
f.close()
info = {}
for l in lines:
l = l.replace('\n', '')
ls = l.split(':')
key = ls[0]
val = ls[1]
info[key] = val
# property
self.L = int(info['L'])
self.N = int(info['N'])
self.M = int(info['M'])
self.directed = (info['directed'] == 'True')
self.edges = edges
#return L, N, directed, edges