File tree 1 file changed +28
-0
lines changed
1 file changed +28
-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
+
6
+
7
+ if __name__ == "__main__" :
8
+ parser = argparse .ArgumentParser (
9
+ description = ("Compute Betweenness for a given graph" )
10
+ )
11
+ parser .add_argument ("input" , help = "path to input graph" )
12
+ parser .add_argument ("dict" , help = "path to input dict" )
13
+ args = parser .parse_args ()
14
+
15
+ graph = None
16
+ labels = {}
17
+
18
+ with open (args .dict , "r" ) as dictfile :
19
+ for line in dictfile :
20
+ vertex , label = line .split ("," , 1 )
21
+ labels [int (vertex )] = label .strip ()[1 :- 1 ]
22
+
23
+ graph = readGraph (args .input , Format .METIS )
24
+ betweenness = centrality .Betweenness (graph )
25
+ ranking = betweenness .run ().ranking ()
26
+
27
+ for vertex , rank in ranking [:20 ]:
28
+ print ("{}. {}" .format (rank , labels [int (vertex + 1 )]))
You can’t perform that action at this time.
0 commit comments