KaGen
KaGen copied to clipboard
Upgrade EdgeRange iterator to bidirectional iterator
Upgrades the EdgeRange iterator from forward-only to bidirectional, enabling backward iteration through graph edges.
Changes
-
Iterator category: Upgraded from
std::forward_iterator_tagtostd::bidirectional_iterator_tag -
Backward iteration operators: Implemented
operator--()(prefix) andoperator--(int)(postfix) -
CSR backward traversal: Added
retreat_to_prev_valid_csr()helper that:- Decrements within vertex adjacency lists
- Navigates to previous vertices when at adjacency list boundaries
- Handles decrement from
end()iterator - Skips empty vertices during backward traversal
- Tests: Added bidirectional iteration tests in parameterized format for both EdgeList and CSR representations
Test Coverage
42 test cases (7 generators × 6 test variations):
- 4 forward iteration tests per generator
- 2 bidirectional iteration tests per generator
All tests pass ✅
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.