KaGen icon indicating copy to clipboard operation
KaGen copied to clipboard

Upgrade EdgeRange iterator to bidirectional iterator

Open Copilot opened this issue 3 months ago • 7 comments

Upgrades the EdgeRange iterator from forward-only to bidirectional, enabling backward iteration through graph edges.

Changes

  • Iterator category: Upgraded from std::forward_iterator_tag to std::bidirectional_iterator_tag
  • Backward iteration operators: Implemented operator--() (prefix) and operator--(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.

Copilot avatar Nov 06 '25 07:11 Copilot