Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def run(self, G):
networkit.correlation.Assortativity(G, networkit.centrality.DegreeCentrality(G).run().scores()).run()
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
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))