Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def getClusteringCoefficient(G):
lcc = centrality.LocalClusteringCoefficient(G, True).run().scores()
return sum(lcc) / n
def run(self, G):
pr = networkit.centrality.PageRank(G, damp=0.85, tol=1e-06)
pr.run()
def run(self, G):
evc = networkit.centrality.EigenvectorCentrality(G, tol=1e-06)
evc.run()
for edge in combinations(related_files_by_id, 2):
togetherness[edge] += 1
finish(s)
s = start("building networkit graph")
g = graph.Graph(weighted=True)
for i in range(len(file_to_id)):
g.addNode()
for e, t in togetherness.items():
g.addEdge(e[0], e[1], 1 / t)
finish(s)
s = start("computing betweenness")
# accurate, slow calculation
b = centrality.Betweenness(g, normalized=True)
# TODO - maybe allow toggling between accurate and estimate methods
# faster but not as precise (10x better in a benchmark test)
# b = networkit.centrality.EstimateBetweenness(g, 128, normalized=True, parallel=True)
b.run()
bb = b.ranking()
finish(s)
if export:
raise NotImplementedError("Not implemented for networkit")
# TODO implement networkit based export
# consider need for node id to filename conversion
# s = start("saving graph to %s" % export)
# networkx.set_node_attributes(graph, values=bb, name="betweenness")
# networkx.write_graphml(graph, export)
# finish(s)
def run(self, G):
mt = networkit.getMaxNumberOfThreads()
networkit.setNumberOfThreads(1)
bc = networkit.centrality.Betweenness(G)
bc.run()
networkit.setNumberOfThreads(mt)
def run(self, G):
kc = networkit.centrality.KatzCentrality(G, tol=1e-06)
kc.run()
def run(self, G):
networkit.centrality.LocalClusteringCoefficient(G).run()