infomap module

class infomap.Infomap

Bases: _InfomapResultsMixin, _InfomapWritersMixin, InfomapWrapper

This class is a thin wrapper around Infomap C++ compiled with SWIG.

Examples

Create an instance and add nodes and links:

>>> from infomap import Infomap
>>> im = Infomap(silent=True)
>>> im.add_node(1)
>>> im.add_node(2)
>>> im.add_link(1, 2)
>>> im.run()
>>> im.codelength
1.0

Create an instance and read a network file:

>>> from infomap import Infomap
>>> im = Infomap(silent=True, num_trials=10)
>>> im.read_file("ninetriangles.net")
>>> im.run()
>>> tol = 1e-4
>>> abs(im.codelength - 3.4622731375264144) < tol
True

For more examples, see the examples directory.

__init__(args=None, cluster_data=None, no_infomap=False, skip_adjust_bipartite_flow=False, bipartite_teleportation=False, weight_threshold=None, include_self_links=None, no_self_links=False, node_limit=None, matchable_multilayer_ids=None, assign_to_neighbouring_module=False, meta_data=None, meta_data_rate=1.0, meta_data_unweighted=False, tree=False, ftree=False, clu=False, verbosity_level=1, silent=False, out_name=None, no_file_output=False, clu_level=None, output=None, hide_bipartite_nodes=False, print_all_trials=False, two_level=False, flow_model=None, directed=None, recorded_teleportation=False, use_node_weights_as_flow=False, to_nodes=False, teleportation_probability=0.15, regularized=False, regularization_strength=1.0, entropy_corrected=False, entropy_correction_strength=1.0, markov_time=1.0, variable_markov_time=False, variable_markov_damping=1.0, preferred_number_of_modules=None, multilayer_relax_rate=0.15, multilayer_relax_limit=-1, multilayer_relax_limit_up=-1, multilayer_relax_limit_down=-1, multilayer_relax_by_jsd=False, seed=123, num_trials=1, core_loop_limit=10, core_level_limit=None, tune_iteration_limit=None, core_loop_codelength_threshold=1e-10, tune_iteration_relative_threshold=1e-05, fast_hierarchical_solution=None, prefer_modular_solution=False, inner_parallelization=False)

Create a new Infomap instance.

Keyword arguments mirror the Infomap CLI flags. Use InfomapOptions for a reusable configuration object and the full parameter reference.

Parameters:

args (str, optional) – Raw Infomap arguments to prepend before rendered keyword options.

Add a link.

Notes

If the source or target nodes does not exist, they will be created.

See also

remove_link

Parameters:
  • source_id (int)

  • target_id (int)

  • weight (float, optional)

Add several links.

Examples

>>> from infomap import Infomap
>>> im = Infomap()
>>> links = (
...     (1, 2),
...     (1, 3)
... )
>>> im.add_links(links)

See also

add_link, remove_link

Parameters:

links (iterable of tuples) – Iterable of tuples of int of the form (source_id, target_id, [weight])

Add an inter-layer link.

Adds a link between two layers in a multilayer network. The link is specified through a shared physical node, but that jump will not be recorded so Infomap will spread out this link to the next possible steps for the random walker in the target layer.

Notes

This multilayer format requires a directed network, so if the directed flag is not present, it will add all links also in their opposite direction to transform the undirected input to directed. If no inter-layer links are added, Infomap will simulate these by relaxing the random walker’s constraint to its current layer. The final state network will be generated on run, which will clear the temporary data structure that holds the provided inter-layer links.

Examples

>>> from infomap import Infomap
>>> im = Infomap()
>>> im.add_multilayer_inter_link(1, 1, 2)
>>> im.add_multilayer_inter_link(1, 2, 2)
>>> im.add_multilayer_inter_link(2, 1, 1)
>>> im.add_multilayer_inter_link(2, 3, 1)
Parameters:
  • source_layer_id (int)

  • node_id (int)

  • target_layer_id (int)

  • weight (float, optional)

Add an intra-layer link.

Adds a link within a layer in a multilayer network.

Examples

>>> from infomap import Infomap
>>> im = Infomap()
>>> im.add_multilayer_intra_link(1, 1, 2)
>>> im.add_multilayer_intra_link(1, 2, 3)
>>> im.add_multilayer_intra_link(2, 1, 3)
>>> im.add_multilayer_intra_link(2, 3, 4)

Notes

This multilayer format requires a directed network, so if the directed flag is not present, it will add all links also in their opposite direction to transform the undirected input to directed. If no inter-layer links are added, Infomap will simulate those by relaxing the random walker’s constraint to its current layer. The final state network will be generated on run, which will clear the temporary data structure that holds the provided intra-layer links.

Parameters:
  • layer_id (int)

  • source_node_id (int)

  • target_node_id (int)

  • weight (float, optional)

Add a multilayer link.

Adds a link between layers in a multilayer network.

Examples

Usage with tuples:

>>> from infomap import Infomap
>>> im = Infomap()
>>> source_multilayer_node = (0, 1) # layer_id, node_id
>>> target_multilayer_node = (1, 2) # layer_id, node_id
>>> im.add_multilayer_link(source_multilayer_node, target_multilayer_node)

Usage with MultilayerNode

>>> from infomap import Infomap, MultilayerNode
>>> im = Infomap()
>>> source_multilayer_node = MultilayerNode(layer_id=0, node_id=1)
>>> target_multilayer_node = MultilayerNode(layer_id=1, node_id=2)
>>> im.add_multilayer_link(source_multilayer_node, target_multilayer_node)

Notes

This is the full multilayer format that supports both undirected and directed links. Infomap will not make any changes to the network.

Parameters:
  • source_multilayer_node (tuple of int, or MultilayerNode) – If passed a tuple, it should be of the format (layer_id, node_id).

  • target_multilayer_node (tuple of int, or MultilayerNode) – If passed a tuple, it should be of the format (layer_id, node_id).

  • weight (float, optional)

Add several multilayer links.

Examples

>>> from infomap import Infomap
>>> im = Infomap()
>>> links = (
...     ((0, 1), (1, 2)),
...     ((0, 3), (1, 2))
... )
>>> im.add_multilayer_links(links)
Parameters:

links (iterable of tuples) – Iterable of tuples of the form (source_node, target_node, [weight])

add_networkx_graph(g, weight='weight', phys_id='phys_id', layer_id='layer_id', multilayer_inter_intra_format=True)

Add a NetworkX graph.

Uses weighted links if present on the weight attribute. Treats the graph as a state network if the phys_id attribute is present and as a multilayer network if also the layer_id attribute is present on the nodes.

Examples

>>> import networkx as nx
>>> from infomap import Infomap
>>> G = nx.Graph([("a", "b"), ("a", "c")])
>>> im = Infomap(silent=True)
>>> mapping = im.add_networkx_graph(G)
>>> mapping
{0: 'a', 1: 'b', 2: 'c'}
>>> im.run()
>>> for node in im.nodes:
...     print(node.node_id, node.module_id, node.flow, mapping[node.node_id])
0 1 0.5 a
1 1 0.25 b
2 1 0.25 c

Usage with a state network

>>> import networkx as nx
>>> from infomap import Infomap
>>> G = nx.Graph()
>>> G.add_node("a", phys_id=1)
>>> G.add_node("b", phys_id=2)
>>> G.add_node("c", phys_id=3)
>>> G.add_node("d", phys_id=1)
>>> G.add_node("e", phys_id=4)
>>> G.add_node("f", phys_id=5)
>>> G.add_edge("a", "b")
>>> G.add_edge("a", "c")
>>> G.add_edge("b", "c")
>>> G.add_edge("d", "e")
>>> G.add_edge("d", "f")
>>> G.add_edge("e", "f")
>>> im = Infomap(silent=True)
>>> mapping = im.add_networkx_graph(G)
>>> mapping
{0: 'a', 1: 'b', 2: 'c', 3: 'd', 4: 'e', 5: 'f'}
>>> im.run()
>>> for node in im.nodes:
...     print(node.state_id, node.node_id, node.module_id, node.flow)
0 1 1 0.16666666666666666
1 2 1 0.16666666666666666
2 3 1 0.16666666666666666
3 1 2 0.16666666666666666
4 4 2 0.16666666666666666
5 5 2 0.16666666666666666

Usage with a multilayer network

>>> import networkx as nx
>>> from infomap import Infomap
>>> G = nx.Graph()
>>> G.add_node(11, phys_id=1, layer_id=1)
>>> G.add_node(21, phys_id=2, layer_id=1)
>>> G.add_node(22, phys_id=2, layer_id=2)
>>> G.add_node(32, phys_id=3, layer_id=2)
>>> G.add_edge(11, 21, weight=2)
>>> G.add_edge(22, 32)
>>> im = Infomap(silent=True)
>>> mapping = im.add_networkx_graph(G)
>>> im.run()
>>> for node in sorted(im.nodes, key=lambda n: n.state_id):
...     print(node.state_id, node.module_id, f"{node.flow:.2f}", node.node_id, node.layer_id)
11 1 0.28 1 1
21 1 0.28 2 1
22 2 0.22 2 2
32 2 0.22 3 2

Notes

Transforms non-int labels to unique int ids. Assumes that all nodes are of the same type. If node type is string, they are added as names to Infomap. If the NetworkX graph is directed (nx.DiGraph), and no flow model has been specified in the constructor, this method sets the directed flag to True.

Parameters:
  • g (nx.Graph) – A NetworkX graph.

  • weight (str, optional) – Key to look up link weight in edge data if present. Default "weight".

  • phys_id (str, optional) – Node attribute for physical node ids, implying a state network.

  • layer_id (str, optional) – Node attribute for layer ids, implying a multilayer network.

  • multilayer_inter_intra_format (bool, optional) – Use intra/inter format to simulate inter-layer links. Default True.

Returns:

Dict with the internal node ids as keys and original labels as values.

Return type:

dict

add_node(node_id, name=None, teleportation_weight=None)

Add a node.

See also

set_name, add_nodes

Parameters:
  • node_id (int)

  • name (str, optional)

  • teleportation_weight (float, optional) – Used for teleporting between layers in multilayer networks.

add_nodes(nodes)

Add nodes.

See also

add_node

Examples

Add nodes

>>> from infomap import Infomap
>>> im = Infomap()
>>> im.add_nodes(range(4))

Add named nodes

>>> from infomap import Infomap
>>> im = Infomap()
>>> nodes = (
...     (1, "Node 1"),
...     (2, "Node 2"),
...     (3, "Node 3")
... )
>>> im.add_nodes(nodes)
>>> im.names
{1: 'Node 1', 2: 'Node 2', 3: 'Node 3'}

Add named nodes with teleportation weights

>>> from infomap import Infomap
>>> im = Infomap()
>>> nodes = (
...     (1, "Node 1", 0.5),
...     (2, "Node 2", 0.2),
...     (3, "Node 3", 0.8)
... )
>>> im.add_nodes(nodes)
>>> im.names
{1: 'Node 1', 2: 'Node 2', 3: 'Node 3'}

Add named nodes using dict

>>> from infomap import Infomap
>>> im = Infomap()
>>> nodes = {
...     1: "Node 1",
...     2: "Node 2",
...     3: "Node 3"
... }
>>> im.add_nodes(nodes)
>>> im.names
{1: 'Node 1', 2: 'Node 2', 3: 'Node 3'}

Add named nodes with teleportation weights using dict

>>> from infomap import Infomap
>>> im = Infomap()
>>> nodes = {
...     1: ("Node 1", 0.5),
...     2: ("Node 2", 0.2),
...     3: ("Node 3", 0.8)
... }
>>> im.add_nodes(nodes)
>>> im.names
{1: 'Node 1', 2: 'Node 2', 3: 'Node 3'}
Parameters:

nodes (iterable of tuples or iterable of int or dict of int: str or dict of int: tuple of (str, float)) – Iterable of tuples on the form (node_id, [name], [teleportation_weight])

add_state_node(state_id, node_id)

Add a state node.

Notes

If a physical node with id node_id does not exist, it will be created. If you want to name the physical node, use set_name.

Parameters:
  • state_id (int)

  • node_id (int) – Id of the physical node the state node should be added to.

add_state_nodes(state_nodes)

Add state nodes.

See also

add_state_node

Examples

With tuples

>>> from infomap import Infomap
>>> im = Infomap()
>>> states = (
...     (1, 1),
...     (2, 1),
...     (3, 2)
... )
>>> im.add_state_nodes(states)

With dict

>>> from infomap import Infomap
>>> im = Infomap()
>>> states = {
...     1: 1,
...     2: 1,
...     3: 2
... }
>>> im.add_state_nodes(states)
Parameters:

state_nodes (iterable of tuples or dict of int: int) – Iterable of tuples of the form (state_id, node_id) or dict of the form {state_id: node_id}.

property bipartite_start_id

Get or set the bipartite start id.

Examples

>>> from infomap import Infomap
>>> im = Infomap(silent=True, num_trials=10)
>>> im.add_node(1, "Left 1")
>>> im.add_node(2, "Left 2")
>>> im.bipartite_start_id = 3
>>> im.add_node(3, "Right 3")
>>> im.add_node(4, "Right 4")
>>> im.add_link(1, 3)
>>> im.add_link(1, 4)
>>> im.add_link(2, 4)
>>> im.run()
>>> tol = 1e-4
>>> abs(im.codelength - 0.9182958340544896) < tol
True
Parameters:

start_id (int) – The node id where the second node type starts.

Returns:

The node id where the second node type starts.

Return type:

int

property codelength

Get the total (hierarchical) codelength.

See also

index_codelength, module_codelength

Returns:

The codelength

Return type:

float

property codelengths

Get the total (hierarchical) codelength for each trial.

See also

codelength

Returns:

The codelengths for each trial

Return type:

tuple of float

classmethod from_options(options, args=None)

Create an Infomap instance from InfomapOptions.

property initial_partition

Get or set the initial partition.

This is a initial configuration of nodes into modules where Infomap will start the optimizer.

Examples

>>> from infomap import Infomap
>>> im = Infomap(silent=True)
>>> im.add_node(1)
>>> im.add_node(2)
>>> im.add_node(3)
>>> im.add_node(4)
>>> im.add_link(1, 2)
>>> im.add_link(1, 3)
>>> im.add_link(2, 3)
>>> im.add_link(2, 4)
>>> im.initial_partition = {
...     1: 0,
...     2: 0,
...     3: 1,
...     4: 1
... }
>>> im.run(no_infomap=True)
>>> tol = 1e-4
>>> abs(im.codelength - 3.4056390622295662) < tol
True

Notes

The initial partition is saved between runs. If you want to use an initial partition for one run only, use run(initial_partition=partition).

Parameters:

module_ids (dict of int, or None) – Dict with node ids as keys and module ids as values.

Returns:

Dict with node ids as keys and module ids as values.

Return type:

dict of int

property network

Get the internal network.

read_file(filename, accumulate=True)

Read network data from file.

Parameters:
  • filename (str)

  • accumulate (bool, optional) – If the network data should be accumulated to already added nodes and links. Default True.

Remove a link.

Notes

Removing links will not remove nodes if they become disconnected.

See also

add_link

Parameters:
  • source_id (int)

  • target_id (int)

Remove several links.

Examples

>>> from infomap import Infomap
>>> im = Infomap()
>>> links = (
...     (1, 2),
...     (1, 3)
... )
>>> im.add_links(links)
>>> im.remove_links(links)
>>> im.num_links
0

See also

remove_link

Parameters:

links (iterable of tuples) – Iterable of tuples of the form (source_id, target_id)

run(args=None, initial_partition=None, cluster_data=None, no_infomap=False, skip_adjust_bipartite_flow=False, bipartite_teleportation=False, weight_threshold=None, include_self_links=None, no_self_links=False, node_limit=None, matchable_multilayer_ids=None, assign_to_neighbouring_module=False, meta_data=None, meta_data_rate=1.0, meta_data_unweighted=False, tree=False, ftree=False, clu=False, verbosity_level=1, silent=False, out_name=None, no_file_output=False, clu_level=None, output=None, hide_bipartite_nodes=False, print_all_trials=False, two_level=False, flow_model=None, directed=None, recorded_teleportation=False, use_node_weights_as_flow=False, to_nodes=False, teleportation_probability=0.15, regularized=False, regularization_strength=1.0, entropy_corrected=False, entropy_correction_strength=1.0, markov_time=1.0, variable_markov_time=False, variable_markov_damping=1.0, preferred_number_of_modules=None, multilayer_relax_rate=0.15, multilayer_relax_limit=-1, multilayer_relax_limit_up=-1, multilayer_relax_limit_down=-1, multilayer_relax_by_jsd=False, seed=123, num_trials=1, core_loop_limit=10, core_level_limit=None, tune_iteration_limit=None, core_loop_codelength_threshold=1e-10, tune_iteration_relative_threshold=1e-05, fast_hierarchical_solution=None, prefer_modular_solution=False, inner_parallelization=False)

Run Infomap.

Keyword arguments mirror the Infomap CLI flags. Use InfomapOptions for the full parameter reference and run_with_options() when reusing a saved configuration.

Parameters:
  • args (str, optional) – Raw Infomap arguments to prepend before rendered keyword options.

  • initial_partition (dict, optional) – Initial partition to use for this run only. See initial_partition.

run_with_options(options, *, args=None, initial_partition=None)

Run Infomap using a reusable InfomapOptions instance.

set_meta_data(node_id, meta_category)

Set meta data to a node.

Examples

>>> from infomap import Infomap
>>> im = Infomap(silent=True, num_trials=10)
>>> im.add_links((
...     (1, 2), (1, 3), (2, 3),
...     (3, 4),
...     (4, 5), (4, 6), (5, 6)
... ))
>>> im.set_meta_data(1, 0)
>>> im.set_meta_data(2, 0)
>>> im.set_meta_data(3, 1)
>>> im.set_meta_data(4, 1)
>>> im.set_meta_data(5, 0)
>>> im.set_meta_data(6, 0)
>>> im.run(meta_data_rate=0)
>>> im.num_top_modules
2
>>> im.run(meta_data_rate=2)
>>> im.num_top_modules
3
Parameters:
  • node_id (int)

  • meta_category (int)

set_name(node_id, name)

Set the name of a node.

Parameters:
  • node_id (int)

  • name (str)

set_names(names)

Set names to several nodes at once.

Examples

With tuples

>>> from infomap import Infomap
>>> im = Infomap()
>>> names = (
...     (1, "Node 1"),
...     (2, "Node 2")
... )
>>> im.set_names(names)
>>> im.names
{1: 'Node 1', 2: 'Node 2'}

With dict

>>> from infomap import Infomap
>>> im = Infomap()
>>> names = {
...     1: "Node 1",
...     2: "Node 2"
... }
>>> im.set_names(names)
>>> im.names
{1: 'Node 1', 2: 'Node 2'}

See also

set_name, names

Parameters:

names (iterable of tuples or dict of int: str) – Iterable of tuples on the form (node_id, name) or dict of the form {node_id: name}.

class infomap.MultilayerNode(layer_id, node_id)

Bases: tuple

layer_id

Alias for field number 0

node_id

Alias for field number 1

class infomap.InfomapOptions(cluster_data: str | None = None, no_infomap: bool = False, skip_adjust_bipartite_flow: bool = False, bipartite_teleportation: bool = False, weight_threshold: float | None = None, include_self_links: bool | None = None, no_self_links: bool = False, node_limit: int | None = None, matchable_multilayer_ids: int | None = None, assign_to_neighbouring_module: bool = False, meta_data: str | None = None, meta_data_rate: float = 1.0, meta_data_unweighted: bool = False, tree: bool = False, ftree: bool = False, clu: bool = False, verbosity_level: int = 1, silent: bool = False, out_name: str | None = None, no_file_output: bool = False, clu_level: int | None = None, output: list[str] | tuple[str, ...] | None = None, hide_bipartite_nodes: bool = False, print_all_trials: bool = False, two_level: bool = False, flow_model: str | None = None, directed: bool | None = None, recorded_teleportation: bool = False, use_node_weights_as_flow: bool = False, to_nodes: bool = False, teleportation_probability: float = 0.15, regularized: bool = False, regularization_strength: float = 1.0, entropy_corrected: bool = False, entropy_correction_strength: float = 1.0, markov_time: float = 1.0, variable_markov_time: bool = False, variable_markov_damping: float = 1.0, preferred_number_of_modules: int | None = None, multilayer_relax_rate: float = 0.15, multilayer_relax_limit: int = -1, multilayer_relax_limit_up: int = -1, multilayer_relax_limit_down: int = -1, multilayer_relax_by_jsd: bool = False, seed: int = 123, num_trials: int = 1, core_loop_limit: int = 10, core_level_limit: int | None = None, tune_iteration_limit: int | None = None, core_loop_codelength_threshold: float = 1e-10, tune_iteration_relative_threshold: float = 1e-05, fast_hierarchical_solution: int | None = None, prefer_modular_solution: bool = False, inner_parallelization: bool = False)

Reusable Infomap keyword options.

This class mirrors the keyword arguments accepted by infomap.Infomap and infomap.Infomap.run(). Use to_args() to render command-line flags, from_mapping() to construct options from existing keyword dicts, or the convenience methods infomap.Infomap.from_options() and infomap.Infomap.run_with_options() to apply a reusable configuration.

Parameters:
  • cluster_data (str, optional) – Provide an initial two-level (clu format) or multi-layer (tree format) solution.

  • no_infomap (bool, optional) – Don’t run the optimizer. Useful to calculate codelength of provided cluster data or to print non-modular statistics.

  • skip_adjust_bipartite_flow (bool, optional) – Skip distributing all flow from the bipartite nodes to the primary nodes.

  • bipartite_teleportation (bool, optional) – Teleport like the bipartite flow instead of two-step (unipartite) teleportation.

  • weight_threshold (float, optional) – Ignore input links with less weight than the threshold.

  • include_self_links (bool, optional) – Deprecated. Self-links are included by default; use no_self_links=True to exclude them.

  • no_self_links (bool, optional) – Exclude self links in the input network.

  • node_limit (int, optional) – Ignore links connected to nodes above the limit.

  • matchable_multilayer_ids (int, optional) – Construct multilayer state ids that are consistent across networks.

  • assign_to_neighbouring_module (bool, optional) – Assign nodes without module assignments from cluster_data to a neighbouring module when possible.

  • meta_data (str, optional) – Provide meta data (clu format) that should be encoded.

  • meta_data_rate (float, optional) – Metadata encoding rate. Default is to encode each step.

  • meta_data_unweighted (bool, optional) – Do not weight meta data by node flow.

  • tree (bool, optional) – Write a tree file with the modular hierarchy.

  • ftree (bool, optional) – Write an ftree file with aggregated links between modules.

  • clu (bool, optional) – Write a clu file with the top cluster ids for each node.

  • verbosity_level (int, optional) – Verbosity level on the console. 1 keeps the default output level, 2 renders -vv and so on.

  • silent (bool, optional) – Disable console output.

  • out_name (str, optional) – Base name for output files.

  • no_file_output (bool, optional) – Disable file output.

  • clu_level (int, optional) – Depth to use for clu output. Use -1 for bottom-level modules.

  • output (sequence of str, optional) – Output formats to request. Options: clu, tree, ftree, newick, json, csv, network, states.

  • hide_bipartite_nodes (bool, optional) – Project bipartite solutions to unipartite output.

  • print_all_trials (bool, optional) – Print all trials to separate files.

  • two_level (bool, optional) – Optimize a two-level partition of the network.

  • flow_model (str, optional) – Flow model. Options: undirected, directed, undirdir, outdirdir, rawdir, precomputed.

  • directed (bool, optional) – Shorthand for flow_model="directed".

  • recorded_teleportation (bool, optional) – Record teleportation when minimizing codelength.

  • use_node_weights_as_flow (bool, optional) – Use node weights as flow and normalize them to sum to 1.

  • to_nodes (bool, optional) – Teleport to nodes instead of links.

  • teleportation_probability (float, optional) – Probability of teleporting to a random node or link.

  • regularized (bool, optional) – Add a fully connected Bayesian prior network to reduce overfitting.

  • regularization_strength (float, optional) – Strength multiplier for the Bayesian prior network.

  • entropy_corrected (bool, optional) – Correct for negative entropy bias in small samples.

  • entropy_correction_strength (float, optional) – Strength multiplier for entropy correction.

  • markov_time (float, optional) – Scale link flow to change the cost of moving between modules.

  • variable_markov_time (bool, optional) – Increase Markov time locally to level out link flow.

  • variable_markov_damping (float, optional) – Exponent for variable Markov time scale. 0 means no rescaling and 1 means full rescaling to constant transition flow rate.

  • preferred_number_of_modules (int, optional) – Penalize solutions by how much they differ from this number.

  • multilayer_relax_rate (float, optional) – Probability to relax the constraint to move only in the current layer.

  • multilayer_relax_limit (int, optional) – Number of neighbouring layers in each direction to relax to. Negative values relax to any layer.

  • multilayer_relax_limit_up (int, optional) – Number of neighbouring layers with higher ids to relax to.

  • multilayer_relax_limit_down (int, optional) – Number of neighbouring layers with lower ids to relax to.

  • multilayer_relax_by_jsd (bool, optional) – Relax proportional to out-link similarity measured by Jensen-Shannon divergence.

  • seed (int, optional) – Random seed for reproducible results.

  • num_trials (int, optional) – Number of outer-most loops to run before picking the best solution.

  • core_loop_limit (int, optional) – Limit the number of core loops.

  • core_level_limit (int, optional) – Limit the number of times core loops are reapplied on the modular network.

  • tune_iteration_limit (int, optional) – Limit the number of main iterations in the two-level partition algorithm. 0 means no limit.

  • core_loop_codelength_threshold (float, optional) – Minimum codelength threshold for accepting a new core-loop solution.

  • tune_iteration_relative_threshold (float, optional) – Codelength improvement threshold for each tune iteration relative to the initial two-level codelength.

  • fast_hierarchical_solution (int, optional) – Find top modules fast. Use 2 to keep all fast levels and 3 to skip the recursive part.

  • prefer_modular_solution (bool, optional) – Prefer modular solutions even if they are worse than the one-module solution.

  • inner_parallelization (bool, optional) – Parallelize the inner-most loop for greater speed with some possible accuracy tradeoff.

class infomap.InfoNode(*args)
property child_degree

The number of children.

Returns:

Number of children

Return type:

int

property flow

Get the flow of the node.

Returns:

The flow

Return type:

float

get_meta_data(dimension=0)

Get meta data on a specific dimension.

Parameters:

dimension (int) – The dimension (default 0)

Returns:

The meta data

Return type:

int

property is_leaf

True if the node has no children.

Returns:

Is leaf node

Return type:

bool

property is_leaf_module

True if the node has children but no grandchildren.

Returns:

Is leaf module

Return type:

bool

property is_root

True if the node has no parent.

Returns:

Is root

Return type:

bool

property layer_id

Get the layer id of a multilayer node.

Returns:

The layer id

Return type:

int

property meta_data

Meta data (on first dimension if more).

Returns:

The meta data

Return type:

int

property node_id

Get the physical node id.

Returns:

The node id

Return type:

int

property state_id

Get the state id of the node.

Returns:

The state id

Return type:

int

class infomap.InfomapIterator(*args)
property child_index

Get the child index.

Returns:

The child index

Return type:

int

property depth

Get the depth.

Returns:

The depth

Return type:

int

property modular_centrality

Get the modular centrality of the node.

Returns:

The modular centrality

Return type:

float

property module_id

Get the module id of the node.

Returns:

The module id

Return type:

int

property path

Get the path to the node in the tree.

Returns:

The path

Return type:

tuple of ints

class infomap.InfomapLeafModuleIterator(*args)
property child_index

Get the child index.

Returns:

The child index

Return type:

int

property depth

Get the depth.

Returns:

The depth

Return type:

int

property modular_centrality

Get the modular centrality of the node.

Returns:

The modular centrality

Return type:

float

property module_id

Get the module id of the node.

Returns:

The module id

Return type:

int

property path

Get the path to the node in the tree.

Returns:

The path

Return type:

tuple of ints

class infomap.InfomapLeafIterator(*args)
property child_index

Get the child index.

Returns:

The child index

Return type:

int

property depth

Get the depth.

Returns:

The depth

Return type:

int

property modular_centrality

Get the modular centrality of the node.

Returns:

The modular centrality

Return type:

float

property module_id

Get the module id of the node.

Returns:

The module id

Return type:

int

property path

Get the path to the node in the tree.

Returns:

The path

Return type:

tuple of ints

class infomap.InfomapIteratorPhysical(*args)
property child_index

Get the child index.

Returns:

The child index

Return type:

int

property depth

Get the depth.

Returns:

The depth

Return type:

int

property modular_centrality

Get the modular centrality of the node.

Returns:

The modular centrality

Return type:

float

property module_id

Get the module id of the node.

Returns:

The module id

Return type:

int

property path

Get the path to the node in the tree.

Returns:

The path

Return type:

tuple of ints

class infomap.InfomapLeafIteratorPhysical(*args)
property child_index

Get the child index.

Returns:

The child index

Return type:

int

property depth

Get the depth.

Returns:

The depth

Return type:

int

property modular_centrality

Get the modular centrality of the node.

Returns:

The modular centrality

Return type:

float

property module_id

Get the module id of the node.

Returns:

The module id

Return type:

int

property path

Get the path to the node in the tree.

Returns:

The path

Return type:

tuple of ints