Tree nodes and iterators
Walking a partition yields nodes via these iterator types. Result.tree()
and Result.leaf_modules() return them (the legacy Infomap.tree() and
friends return the same objects). Each step yields an iterator positioned at the
current node, proxying the attributes of the underlying InfoNode
(available via current()).
-
class infomap.InfoNode(*args)
A node in the hierarchical partition tree.
The underlying node type of the tree-walking iterators on Infomap
(Infomap.tree(), Infomap.nodes(), and friends); the iterators
proxy its attributes and expose it directly via their current() method.
Exposes the node’s ids, flow, and position in the tree as properties.
-
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 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
-
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
State-node iterators
-
class infomap.InfomapIterator(*args)
Depth-first pre-order iterator over the full partition tree, modules and
leaf nodes alike. Returned by Infomap.tree(). Each step exposes the
current node’s attributes (module_id, path, depth, flow, …)
directly on the iterator.
-
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)
Iterator over the leaf modules of the partition tree (modules whose children
are leaf nodes). Returned by Infomap.leaf_modules().
-
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)
Iterator over the leaf nodes of the partition tree. Returned by
Infomap.nodes().
-
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
Physical-node iterators
-
class infomap.InfomapIteratorPhysical(*args)
Like InfomapIterator, but aggregates state nodes belonging to the
same physical node within each leaf module. Returned by
Infomap.physical_tree() for memory networks.
-
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)
Iterator over the leaf nodes of the partition tree, aggregating state nodes
belonging to the same physical node within each leaf module.
-
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