How to use the networkit.community 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 / sparsification.py View on Github external
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
github networkit / networkit / networkit / properties.py View on Github external
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"]:
github networkit / networkit / benchmark / nk.py View on Github external
def run(self, G):
		plm = networkit.community.PLM(G, turbo=True)
		plm.run()
github networkit / networkit / networkit / sparsification.py View on Github external
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
github networkit / networkit / networkit / properties.py View on Github external
# 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"]:
github networkit / networkit / benchmark / nk.py View on Github external
def run(self, G):
		plm = networkit.community.PLP(G)
		plm.run()