Skip to content

Implement iteration over nodes in depth-first traversal order #530

@tturocy

Description

@tturocy

There are some algorithms (e.g. the information set graph mentioned in #484) where we want to iterate over the nodes of the game using depth-first traversal.

Implementation a Nodes class as a member of a GameRep. This class should implement an iterator that starts from the root node and successively returns nodes in depth-first traversal order - i.e. the root node first, then the first child of the root node (if any), then the first child of that node (if any), and so on.

Then, in Python, there is currently a class which implements this same idea, including the depth-first search done as a recursive generator. The python implementation can be replaced by a wrapper on the C++ implementation.

Note that the implementation of the iterator in C++ won't be recursive - the most straightforward implementation would be to have a list of iterators over child nodes which functions as a stack.

Tests in Python can be updated accordingly as required.

Metadata

Metadata

Assignees

Labels

c++Items which involve writing in C++pythonItems which involve coding in Python

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions