-
Notifications
You must be signed in to change notification settings - Fork 2
/
twitter.py
35 lines (26 loc) · 1.01 KB
/
twitter.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
import networkx as nx
import timeit
import SingleViewKernel as sg
def add_edges_from(G, edgefile):
efile = open(edgefile, 'r')
for line in efile:
split = line.split(' ')
srcnd = int(split[0])
endnd = split[1]
if endnd[-1]=='\n':
endnd = int(endnd[:-1])
G.add_edge(srcnd, endnd)
return G
G = nx.Graph()
start = timeit.default_timer()
#G_reply = nx.read_edgelist('/home/parul/repos/twitter_multi_view/reply.txt', nodetype=int)
#G_mention = nx.read_edgelist('/home/parul/repos/twitter_multi_view/mention.txt', nodetype=int)
#G_retweet = nx.read_edgelist('/home/parul/repos/twitter_multi_view/retweet.txt', nodetype=int)
#G_social = nx.read_edgelist('/home/parul/repos/twitter_multi_view/social1.txt', nodetype=int)
#G_social = add_edges_from(G_social, '/home/parul/repos/twitter_multi_view/social2.txt')
G = nx.gnm_random_graph(100,1000,directed=False)
print (sg.find_kernel(G))
stop = timeit.default_timer()
print (stop-start)
#outf = '/home/parul/repos/twitter_multi_view/reply.graphml'
#nx.write_graphml(G, outf)