Top-level functions¶
Graph-package entry points¶
- infomap.find_communities(g: Any, *, weight: str | None = 'weight', node_id: str = 'node_id', layer_id: str = 'layer_id', multilayer_inter_intra_format: bool = True, initial_partition: Any = None, module_attribute: str | None = None, flow_attribute: str | None = None, **infomap_options: Any) list[set[Any]]¶
Find communities in a NetworkX-style graph.
This helper is duck-typed and does not import NetworkX. It accepts the same graph objects as
Infomap.add_networkx_graph(), runs Infomap, and returns communities using the original graph node labels.- Parameters:
g (nx.Graph) – A NetworkX-compatible graph.
weight (str or None, optional) – Key to look up link weight in edge data if present. Default
"weight". UseNoneto treat every edge as weight 1.node_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.module_attribute (str, optional) – If set, write each node’s module id back to this node attribute on
g.flow_attribute (str, optional) – If set, write each node’s flow back to this node attribute on
g.initial_partition (mapping, optional) – Initial module assignment passed to
infomap.Infomap.run(). Keys may use the original NetworkX node labels.**infomap_options – Keyword arguments passed to
infomap.Infomap. By default,silent=Trueandno_file_output=Trueare used unless explicitly overridden.
- Returns:
A partition of
g.nodesgrouped by top-level Infomap module.- Return type:
- infomap.find_igraph_communities(g: Any, *, edge_weights: str | Iterable[Any] | None = None, vertex_weights: Any = None, trials: int = 10, node_id: str = 'node_id', layer_id: str = 'layer_id', multilayer_inter_intra_format: bool = True, module_attribute: str | None = None, flow_attribute: str | None = None, **infomap_options: Any) Any¶
Find communities in a python-igraph graph.
- infomap.tl.infomap(adata: Any, *, adjacency: Any = None, directed: bool = False, use_weights: bool = True, key_added: str = 'infomap', neighbors_key: str | None = None, obsp: str | None = None, copy: bool = False, args: str | None = None, **infomap_options: Any) Any¶
Run Infomap on an AnnData observation graph.
This function follows Scanpy
tlconventions: by default it readsadata.obsp["connectivities"], writes categorical module labels toadata.obs[key_added], and stores run metadata inadata.uns[key_added]. Scanpy itself is not imported.
Information-theoretic primitives¶
- infomap.entropy(p)¶
- infomap.perplexity(p)¶
- infomap.plogp(p)¶