How to use the networkit.correlation.Assortativity 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 / benchmark / nk.py View on Github external
def run(self, G):
		networkit.correlation.Assortativity(G, networkit.centrality.DegreeCentrality(G).run().scores()).run()
github networkit / networkit / networkit / profiling / profiling.py View on Github external
self.verbosePrint("    Sort: ", end="")
			timerPostSort = stopwatch.Timer()
			measure["data"]["sorted"] = stat.sorted(measure["data"]["sample"])
			elapsedPostSort = timerPostSort.elapsed
			self.verbosePrint("{:.2F} s".format(elapsedPostSort))

			self.verbosePrint("    Rank: ", end="")
			timerPostRank = stopwatch.Timer()
			measure["data"]["ranked"] = stat.ranked(measure["data"]["sample"])
			elapsedPostRank = timerPostRank.elapsed
			self.verbosePrint("{:.2F} s".format(elapsedPostRank))

			if self.__measures[name]["category"] == "Node Centrality":
				self.verbosePrint("    Assortativity: ", end="")
				timerPostAssortativity = stopwatch.Timer()
				assortativity = kit.correlation.Assortativity(self.__G, measure["data"]["sample"])
				assortativity.run()
				measure["assortativity"] = assortativity.getCoefficient()
				elapsedPostAssortativity = timerPostAssortativity.elapsed
				self.verbosePrint("{:.2F} s".format(elapsedPostAssortativity))
			else:
				measure["assortativity"] = float("nan")

			if self.__measures[name]["category"] == "Node Centrality":
				self.verbosePrint("    Centralization: ", end="")
				timerPostCentralization = stopwatch.Timer()
				try:
					measure["centralization"] = instance.centralization()
				except:
					self.verbosePrint("Centrality.centralization not properly defined for {0}. ".format(name), level=0, end="")
					measure["centralization"] = float("nan")
				elapsedPostCentralization = timerPostCentralization.elapsed
github networkit / networkit / networkit / __init__.py View on Github external
print("Network Properties for:\t\t{}".format(G.getName()))
	print("nodes, edges\t\t\t{}, {}".format(n, G.numberOfEdges()))
	print("directed?\t\t\t{}".format("True" if G.isDirected() else "False"))
	print("weighted?\t\t\t{}".format("True" if G.isWeighted() else "False"))
	print("isolated nodes\t\t\t{}".format(getIsolatedNodes(degrees)))
	print("self-loops\t\t\t{}".format(numSelfLoops))
	print("density\t\t\t\t{:.6f}".format(graphtools.density(G)))
	if numSelfLoops == 0 and not G.isDirected():
		print("clustering coefficient\t\t{:.6f}".format(
			getClusteringCoefficient(G)))
	print("min/max/avg degree\t\t{:d}, {:d}, {:.6f}".format(
		int(min(degrees)), int(max(degrees)),
		sum(degrees) / n))
	print("degree assortativity\t\t{:.6f}".format(
		correlation.Assortativity(G, degrees).run().getCoefficient()))
	cp = getComponentPartition(G)
	lcs = max(cp.subsetSizes())
	print("number of connected components\t{}".format(cp.numberOfSubsets()))
	print("size of largest component\t{} ({:.2f} %)".format(
		lcs, 100 * lcs / n))