Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def scores(self, G):
""" Returns an edge attribute that holds for each edge the minimum parameter value
such that the edge is contained in the sparsified graph.
Keyword arguments:
G -- the input graph
"""
cdAlgo = community.PLM(G, refine=True, turbo=True)
cdAlgo.run()
partition = cdAlgo.getPartition()
def together(u, v):
if (partition[u] == partition[v]):
return 1.0
else:
return 0.0
# FIXME: with respect to performance, the following is wrong on so many levels - don't try this at home
edgeScores = [None for i in range(G.upperEdgeIdBound())]
for (u, v) in G.edges():
edgeScores[G.edgeId(u, v)] = together(u, v)
return edgeScores
loops = G.numberOfSelfLoops()
# density
dens = density(G)
# community detection
ncomPLP, modPLP = None, None
ncomPLM, modPLM = None, None
if settings["communities"]:
logging.info("[...] detecting communities")
# perform PLM community detection
logging.info("[...] performing community detection: PLM")
plm = community.PLM()
print(plm)
zetaPLM = plm.run(G)
ncomPLM = zetaPLM.numberOfSubsets()
modPLM = community.Modularity().getQuality(zetaPLM, G)
# degree histogram
labels, histo = None, None
if settings["degreeHistogram"]:
logging.info("[...] preparing degree histogram")
histo = degDist
(labels, histo) = compressHistogram(histo, nbins=25)
# connected components
nComponents, componentSizes = None, None
if settings["components"]:
def run(self, G):
plm = networkit.community.PLM(G, turbo=True)
plm.run()
def getAttribute(self, G):
""" Returns an edge attribute that holds for each edge the minimum parameter value
such that the edge is contained in the sparsified graph.
Keyword arguments:
G -- the input graph
"""
cdAlgo = community.PLM(G, refine=True, turbo=True)
cdAlgo.run()
partition = cdAlgo.getPartition()
def together(u, v):
if (partition[u] == partition[v]):
return 1.0
else:
return 0.0
# FIXME: with respect to performance, the following is wrong on so many levels - don't try this at home
edgeScores = [None for i in range(G.upperEdgeIdBound())]
for (u, v) in G.edges():
edgeScores[G.edgeId(u, v)] = together(u, v)
return edgeScores
# community detection
ncomPLP, modPLP = None, None
ncomPLM, modPLM = None, None
if settings["communities"]:
logging.info("[...] detecting communities")
# perform PLM community detection
logging.info("[...] performing community detection: PLM")
plm = community.PLM()
print(plm)
zetaPLM = plm.run(G)
ncomPLM = zetaPLM.numberOfSubsets()
modPLM = community.Modularity().getQuality(zetaPLM, G)
# degree histogram
labels, histo = None, None
if settings["degreeHistogram"]:
logging.info("[...] preparing degree histogram")
histo = degDist
(labels, histo) = compressHistogram(histo, nbins=25)
# connected components
nComponents, componentSizes = None, None
if settings["components"]:
nComponents, componentSizes = components(G)
# diameter
if settings["diameter"]:
def run(self, G):
plm = networkit.community.PLP(G)
plm.run()