Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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)