-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_small_subgraphs.py
119 lines (110 loc) · 3.07 KB
/
test_small_subgraphs.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import snap
def get_users_unweighted(G):
print "reading users"
f = open("user_small_test.txt", "w")
for n in G.Nodes():
n = n.GetId()
if n > 31097108: G.DelNode(n)
nodes = sorted([n.GetId() for n in G.Nodes()])
u_edges = {}
count = 0
for n in nodes:
if n > 18630353: break
users = snap.TIntV()
snap.GetNodesAtHop(G, n, 2, users, False)
for u in users:
f.write(str(n) + "\t" + str(u) + '\n')
G.DelNode(n)
if count%10000 == 0: print count
count += 1
f.close()
print "users read"
def get_pins_unweighted(G):
print "reading pins"
f = open("pins_small_test.txt", "w")
for n in G.Nodes():
n = n.GetId()
if n <= 18630353: G.DelNode(n)
nodes = sorted([n.GetId() for n in G.Nodes()], reverse=True)
u_edges = {}
count = 0
for n in nodes:
if n <= 31097108: break
pins = snap.TIntV()
snap.GetNodesAtHop(G, n, 2, pins, False)
for p in pins:
f.write(str(n) + "\t" + str(p) + '\n')
G.DelNode(n)
if count%10000 == 0: print count
count += 1
f.close()
print "pins read"
def get_board_users_unweighted(G):
print "reading boards"
f = open("user_board_small_test.txt", "w")
for n in G.Nodes():
n = n.GetId()
if n > 31097108: G.DelNode(n)
nodes = sorted([n.GetId() for n in G.Nodes()], reverse=True)
count = 0
for n in nodes:
if n <= 18630353: break
boards = snap.TIntV()
snap.GetNodesAtHop(G, n, 2, boards, False)
for b in boards:
f.write(str(n) + "\t" + str(b) + '\n')
G.DelNode(n)
if count%10000 == 0: print count
count += 1
f.close()
def get_board_pins_unweighted(G):
print "reading boards"
f = open("pin_board_small_test.txt", "w")
for n in G.Nodes():
n = n.GetId()
if n <= 18630353: G.DelNode(n)
nodes = sorted([n.GetId() for n in G.Nodes()])
count = 0
for n in nodes:
if n > 31097108: break
boards = snap.TIntV()
snap.GetNodesAtHop(G, n, 2, boards, False)
for b in boards:
f.write(str(n) + "\t" + str(b) + '\n')
G.DelNode(n)
if count%10000 == 0: print count
count += 1
f.close()
def get_board_unweighted(G):
print "reading boards"
f = open("board_small_test.txt", "w")
nodes = sorted([n.GetId() for n in G.Nodes()])
count = 0
for n in nodes:
if n <= 18630353: continue
if n > 31097108: break
boards = snap.TIntV()
snap.GetNodesAtHop(G, n, 2, boards, False)
for b in boards:
if b > 18630353 and b <= 31097108: f.write(str(n) + "\t" + str(b) + '\n')
G.DelNode(n)
if count%10000 == 0: print count
count += 1
f.close()
def main():
G = snap.LoadEdgeList(snap.PUNGraph, "smallest_test_graph.txt", 0, 1)
G.DelNode(0)
get_users_unweighted(G)
G = snap.LoadEdgeList(snap.PUNGraph, "smallest_test_graph.txt", 0, 1)
G.DelNode(0)
get_board_users_unweighted(G)
G = snap.LoadEdgeList(snap.PUNGraph, "smallest_test_graph.txt", 0, 1)
G.DelNode(0)
get_pins_unweighted(G)
G = snap.LoadEdgeList(snap.PUNGraph, "smallest_test_graph.txt", 0, 1)
G.DelNode(0)
get_board_pins_unweighted(G)
G = snap.LoadEdgeList(snap.PUNGraph, "smallest_test_graph.txt", 0, 1)
G.DelNode(0)
get_board_unweighted(G)
main()