How to use the infomap.infomap.Infomap 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 SkBlaz / Py3plex / py3plex / algorithms / community_detection / community_ranking.py View on Github external
def return_infomap_communities(network):

    infomapWrapper = infomap.Infomap("--two-level --silent")

    # Add link weight as an optional third argument
    for e in network.edges():
        infomapWrapper.addLink(e[0], e[1])
    infomapWrapper.run()
    tree = infomapWrapper.tree
    print("Found %d modules with codelength: %f" % (tree.numTopModules(), tree.codelength()))
    print("\n#node module")
    part = defaultdict(list)
    for node in tree.leafIter():
        part[node.moduleIndex()].append(node.physIndex)
    return list(part.values())
github SkBlaz / Py3plex / py3plex / algorithms / community_detection / infomap / examples / python / example-bipartite.py View on Github external
from infomap import infomap

infomapWrapper = infomap.Infomap("--two-level")

# Set the start index for bipartite nodes
infomapWrapper.setBipartiteNodesFrom(5)
# Add weight as an optional third argument
infomapWrapper.addLink(5, 0)
infomapWrapper.addLink(5, 1)
infomapWrapper.addLink(5, 2)
infomapWrapper.addLink(6, 2)
infomapWrapper.addLink(6, 3)
infomapWrapper.addLink(6, 4)

infomapWrapper.run()

tree = infomapWrapper.tree

print("Found %d modules with codelength: %f" % (tree.numTopModules(), tree.codelength()))
github SkBlaz / Py3plex / py3plex / algorithms / community_detection / community_ranking.py View on Github external
def return_infomap_communities(network):

    infomapWrapper = infomap.Infomap("--two-level --silent")

    # Add link weight as an optional third argument
    for e in network.edges():
        infomapWrapper.addLink(e[0], e[1])
    infomapWrapper.run()
    tree = infomapWrapper.tree
    print("Found %d modules with codelength: %f" % (tree.numTopModules(), tree.codelength()))
    print("\n#node module")
    part = defaultdict(list)
    for node in tree.leafIter():
        part[node.moduleIndex()].append(node.physIndex)
    return list(part.values())
github SkBlaz / Py3plex / py3plex / algorithms / community_detection / infomap / examples / python / example-simple.py View on Github external
from infomap import infomap

infomapWrapper = infomap.Infomap("--two-level")

# Add weight as an optional third argument
infomapWrapper.addLink(0, 1)
infomapWrapper.addLink(0, 2)
infomapWrapper.addLink(0, 3)
infomapWrapper.addLink(1, 0)
infomapWrapper.addLink(1, 2)
infomapWrapper.addLink(2, 1)
infomapWrapper.addLink(2, 0)
infomapWrapper.addLink(3, 0)
infomapWrapper.addLink(3, 4)
infomapWrapper.addLink(3, 5)
infomapWrapper.addLink(4, 3)
infomapWrapper.addLink(4, 5)
infomapWrapper.addLink(5, 4)
infomapWrapper.addLink(5, 3)
github SkBlaz / Py3plex / py3plex / algorithms / community_detection / infomap / examples / python / example-networkx.py View on Github external
def findCommunities(G):
	"""
	Partition network with the Infomap algorithm.
	Annotates nodes with 'community' id and return number of communities found.
	"""
	
	infomapWrapper = infomap.Infomap("--two-level")

	print("Building Infomap network from a NetworkX graph...")
	for e in G.edges():
		infomapWrapper.addLink(*e)

	print("Find communities with Infomap...")
	infomapWrapper.run();

	tree = infomapWrapper.tree

	print("Found %d top modules with codelength: %f" % (tree.numTopModules(), tree.codelength()))

	communities = {}
	for node in tree.leafIter():
		communities[node.originalLeafIndex] = node.moduleIndex()

infomap

Infomap network clustering algorithm

GPL-3.0
Latest version published 6 months ago

Package Health Score

65 / 100
Full package analysis