In [1]:
from networkit import *



In [2]:
# we find the k nodes with highest closeness in a graph
G = readGraph("input/PGPgiantcompo.graph", Format.METIS)

In [3]:
k = 10

In [12]:
# The last two parameters indicate which heuristics we want to use.
# We recommend using True, False for complex networks and True, True for street networks
topk = centrality.TopCloseness(G, k, True, False)
%time topk.run()


CPU times: user 1.64 s, sys: 25.4 ms, total: 1.67 s
Wall time: 493 ms
Out[12]:
<_NetworKit.TopCloseness at 0x10ffc2898>

In [8]:
cc = centrality.Closeness(G)
%time cc.run()


CPU times: user 1min 19s, sys: 600 ms, total: 1min 19s
Wall time: 22.4 s
Out[8]:
<_NetworKit.Closeness at 0x10ffc2550>

In [13]:
topk.topkNodesList()


Out[13]:
[1143, 6655, 6555, 1435, 7297, 6859, 6744, 6768, 6098, 2258]

In [14]:
cc.ranking()[:k]


Out[14]:
[(1143, 2.1164469089292894e-05),
 (6655, 2.0922252908193154e-05),
 (6555, 2.0463707614545603e-05),
 (1435, 2.0415246105791806e-05),
 (7297, 2.0345466012899025e-05),
 (6859, 2.0323550930818634e-05),
 (6744, 2.0264245764772636e-05),
 (6768, 1.9864129355210362e-05),
 (6098, 1.9855452307203558e-05),
 (2258, 1.9812573058863156e-05)]

In [ ]: