-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path1
executable file
·59 lines (46 loc) · 1.3 KB
/
1
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
import pandas as pd
import numpy as np
import networkx as nx
import pickle
dataset_edges = pd.read_csv('enrondatasetfinal.csv')
dataset_nodes = pd.read_csv('Enron.true', sep = ';')
node_from = dataset_edges.iloc[:,0].values
node_to = dataset_edges.iloc[:,1].values
num_nodes = len(dataset_nodes)
print num_nodes
# Creare graph
G = nx.Graph()
for i, j in zip(node_from, node_to):
G.add_edge(i, j)
'''
d_bet_cen = dict()
d_bet_cen = nx.betweenness_centrality(G)
d_degree = G.degree(G.nodes())
output = open('bet_cen_dict.pkl', 'wb')
pickle.dump(d_bet_cen, output)
output.close()
'''
#Reading between central dictionary pickle file
pkl_file = open('bet_cen_dict.pkl','rb')
d_bet_cen =pickle.load(pkl_file)
#Reading degree dictionary pickle file
pkl_file2 = open('degree_list_tup.pkl', 'rb')
d_degree = pickle.load(pkl_file2)
# l = filter(lambda x:x[1]>=0.0000001,d_bet_cen.items())
# print len(l)
# print min(d_bet_cen.items(), key = lambda x:x[1])
cnt = 0
for k1, v1, k2, v2 in zip(d_bet_cen.iteritems(),d_degree.iteritems()):
if k1>0.0000001 and k2>70:
cnt+= 1
print cnt
'''
outfile = open('bet_cen_enron_data.txt', 'w')
for i, j in d_bet_cen.iteritems():
if j >= 0.0000001:
outfile.write(str(i) + " 1\n")
else:
outfile.write(str(i) + " 0\n")
outfile.close()
pkl_file.close()
'''