How to use the networkit.centrality function in networkit

To help you get started, we’ve selected a few networkit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github networkit / networkit / networkit / __init__.py View on Github external
def getClusteringCoefficient(G):
		lcc = centrality.LocalClusteringCoefficient(G, True).run().scores()
		return sum(lcc) / n
github networkit / networkit / benchmark / nk.py View on Github external
def run(self, G):
		pr = networkit.centrality.PageRank(G, damp=0.85, tol=1e-06)
		pr.run()
github networkit / networkit / benchmark / nk.py View on Github external
def run(self, G):
		evc = networkit.centrality.EigenvectorCentrality(G, tol=1e-06)
		evc.run()
github jeffgreenca / codesort / codesort.py View on Github external
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)
github networkit / networkit / benchmark / nk.py View on Github external
def run(self, G):
		mt = networkit.getMaxNumberOfThreads()
		networkit.setNumberOfThreads(1)
		bc = networkit.centrality.Betweenness(G)
		bc.run()
		networkit.setNumberOfThreads(mt)
github networkit / networkit / benchmark / nk.py View on Github external
def run(self, G):
		kc = networkit.centrality.KatzCentrality(G, tol=1e-06)
		kc.run()
github networkit / networkit / benchmark / nk.py View on Github external
def run(self, G):
		networkit.centrality.LocalClusteringCoefficient(G).run()