Skip to content

Commit 6b91184

Browse files
committed
fix(python): Expose num_non_trivial_top_modules
Recalculate after replacing best tree
1 parent 002986e commit 6b91184

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

interfaces/python/infomap.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,19 @@ def num_top_modules(self):
875875
"""
876876
return super().numTopModules()
877877

878+
@property
879+
def num_non_trivial_top_modules(self):
880+
"""Get the number of non-trivial top modules in the tree
881+
882+
A trivial module is a module with either one or all nodes within.
883+
884+
Returns
885+
-------
886+
int
887+
The number of non-trivial top modules
888+
"""
889+
return super().numNonTrivialTopModules()
890+
878891
@property
879892
def num_leaf_modules(self):
880893
"""Get the number of leaf modules in the tree

src/core/InfomapBase.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ InfomapBase& InfomapBase::initTree(const NodePaths& tree)
604604

605605
aggregateFlowValuesFromLeafToRoot();
606606
initNetwork();
607+
calculateNumNonTrivialTopModules();
607608

608609
m_hierarchicalCodelength = calcCodelengthOnTree(true);
609610
Log() << "\n -> Initiated to codelength " << m_hierarchicalCodelength << " in " << maxDepth << " levels with " << numTopModules() << " top modules." << std::endl;

0 commit comments

Comments
 (0)