How to use the infomap.findBestPartition function in infomap

To help you get started, we’ve selected a few infomap 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 reyagroup / networkx_additional_algorithms / community / community.py View on Github external
runs the infomap community detection algorithm numTrials times, and returns the "agreement" between the runs
	
	graph: a networkx graph

	numTrials: number of runs of the infomap algorithm

	setSimilarityThreshold,voteThreshold: see findAgreementBetween
	
	returns a dictionary mapping node->[list of communities node belongs to]
	if returnFullHistogram is set to True, then voteThreshold will be ignored and a list of tuples will be returned
	in the form, for every community, (community representative, number of trials that 'voted' for this community)
	
	A 'representative' will be chosen for each community, and it will be the set that is present in the return value.
	It is the one which has the highest similarity to all the other sets in it's super-class
	"""
	runs = [findBestPartition(graph,partitionOnly=False) for t in xrange(numTrials)]
	trials = [c[1].values() for c in runs]
	
	agree = findAgreementBetween(trials,setSimilarityThreshold=setSimilarityThreshold,voteThreshold=voteThreshold,returnFullHistogram=returnFullHistogram)
	
	if returnFullHistogram:
		return agree
	
	partition = {}
	for cet in xrange(len(agree)):
		for node in agree[cet]:
			if node not in partition:
				partition[node] = []
			partition[node].append(cet)
			
	return partition

infomap

Infomap network clustering algorithm

GPL-3.0
Latest version published 5 months ago

Package Health Score

70 / 100
Full package analysis