Skip to content

Commit c3a0c90

Browse files
author
Anton Eriksson
committed
fix: Module ids wrong for uneven depth and chosen level > 1
Fixes #221
1 parent 0d4cc37 commit c3a0c90

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/core/InfomapIterator.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,6 @@ InfomapIterator& InfomapIterator::operator++()
4444
m_current = nullptr;
4545
return *this;
4646
}
47-
48-
if (m_moduleIndexLevel < 0) {
49-
if (current->isLeafModule()) { // TODO: Generalize to -2 for second level to bottom
50-
++m_moduleIndex;
51-
}
52-
} else if (static_cast<unsigned int>(m_moduleIndexLevel) == m_depth) {
53-
++m_moduleIndex;
54-
}
5547
} else { // null also if no children in first place
5648
m_current = nullptr;
5749
return *this;
@@ -60,6 +52,11 @@ InfomapIterator& InfomapIterator::operator++()
6052
}
6153

6254
current = current->next;
55+
56+
if (!current->isLeaf() && (m_moduleIndex < 0 || static_cast<unsigned int>(m_moduleIndexLevel) >= m_depth)) {
57+
++m_moduleIndex;
58+
}
59+
6360
++m_path.back();
6461
}
6562

0 commit comments

Comments
 (0)