Skip to content

Implement iteration over nodes in DFT order; expose it to Cython#531

Closed
d-kad wants to merge 2 commits into
gambitproject:masterfrom
d-kad:issue_530
Closed

Implement iteration over nodes in DFT order; expose it to Cython#531
d-kad wants to merge 2 commits into
gambitproject:masterfrom
d-kad:issue_530

Conversation

@d-kad

@d-kad d-kad commented Jun 24, 2025

Copy link
Copy Markdown
Contributor

Introduced a new nested class, GameRep::Nodes, which acts as a standard C++ forward iterator.

  • This iterator performs a depth-first, pre-order traversal of the game tree, starting from the root.
  • The GameRep class is now directly iterable, through the addition of: begin() and end() methods
  • const overloads for both methods to ensure const-correctness in functions like IsPerfectRecall().

Closes #530

@d-kad d-kad requested a review from tturocy June 24, 2025 12:23
Comment thread src/games/game.h Outdated
Comment thread src/pygambit/game.pxi Outdated
Comment thread src/pygambit/game.pxi Outdated
Comment thread tests/test_node.py Outdated
Comment thread src/games/game.h Outdated
Comment thread src/games/game.h
Comment thread src/games/game.h Outdated
Comment thread src/games/game.h Outdated
Comment thread src/pygambit/game.pxi Outdated
Comment thread src/pygambit/game.pxi Outdated
@d-kad

d-kad commented Jul 4, 2025

Copy link
Copy Markdown
Contributor Author

@tturocy I implemented node traversal in operator++ with a single children iterator on stack using exception catching mechanism (mirroring your Python code snippet for the PR-checker)

@tturocy tturocy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this looks to be converging well towards a solution please do squash on the next iteration and give a good candidate commit message.

Comment thread src/games/game.h Outdated
Comment thread src/games/game.h Outdated
Comment thread src/games/game.h Outdated
Comment thread src/games/game.h Outdated
Comment thread src/pygambit/game.pxi Outdated
Comment thread tests/test_node.py
Comment thread tests/test_node.py Outdated
…FT order. Change Python API to use the new nodes iterator. Add tests.
Comment thread tests/test_node.py Outdated
Comment thread tests/test_node.py Outdated
Comment thread src/games/game.h Outdated
@tturocy

tturocy commented Jul 10, 2025

Copy link
Copy Markdown
Member

Merged as 89cbddc with some minor adjustments.

@tturocy tturocy closed this Jul 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement iteration over nodes in depth-first traversal order

2 participants