How to use the networkit.centrality.DegreeCentrality 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 overview(G):
	"""
		This function collects some basic information about the given graph and prints it to the terminal.
	"""
	n = G.numberOfNodes()
	degrees = centrality.DegreeCentrality(
		G, ignoreSelfLoops=G.numberOfSelfLoops() == 0).run().scores()
	numSelfLoops = G.numberOfSelfLoops()

	def getIsolatedNodes(degrees):
		sequence = sorted(degrees)
		i = 0
		nIsolated = 0
		while i < len(sequence) and sequence[i] == 0:
			nIsolated += 1
			i += 1
		return nIsolated

	def getClusteringCoefficient(G):
		lcc = centrality.LocalClusteringCoefficient(G, True).run().scores()
		return sum(lcc) / n
github networkit / networkit / networkit / viztasks.py View on Github external
def drawGraph(G, **kwargs):
	""" Draws a graph via networkX. Passes additional arguments beyond the graph to networkx.draw(...).
	    By default, node sizes are scaled between 30 and 300 by node degree.
	"""
	if not have_nx:
		raise MissingDependencyError("networkx")
	nxG = nxadapter.nk2nx(G)
	if not "node_size" in kwargs:
		kwargs["node_size"] =[30+270*s for s in centrality.DegreeCentrality(G,True).run().scores()],
	networkx.draw(nxG, **kwargs)