File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python3
2
+
3
+ import argparse
4
+ from networkit import *
5
+ from operator import itemgetter
6
+ from collections import defaultdict
7
+
8
+
9
+ if __name__ == '__main__' :
10
+ parser = argparse .ArgumentParser (description = ("Compute Betweenness for a given graph" ))
11
+ parser .add_argument ('input' ,
12
+ help = 'path to input graph' )
13
+ parser .add_argument ('dict' ,
14
+ help = 'path to input dict' )
15
+ args = parser .parse_args ()
16
+
17
+ graph = None
18
+ labels = {}
19
+
20
+ with open (args .dict , 'r' ) as dictfile :
21
+ for line in dictfile :
22
+ vertex , label = line .split (',' , 1 )
23
+ labels [int (vertex )] = label .strip ()[1 :- 1 ]
24
+
25
+ graph = readGraph (args .input , Format .METIS )
26
+ betweenness = centrality .Betweenness (graph )
27
+ ranking = betweenness .run ().ranking ()
28
+
29
+ for vertex , rank in ranking [:20 ]:
30
+ print ('{}. {}' .format (rank , labels [int (vertex + 1 )]))
You can’t perform that action at this time.
0 commit comments