When I was working on traversing the graph I ran into some issues in the recursion.
First among these was recursing over already-queried Players (who had also been appended into the player_cache).
My naive solution to this was first to add a second parameter into the recursion function to allow checking for backtracking. I then determined I could simplify this by using player_cache.
I now believe this may have been a mistake.
The reason: a Player skipped due to backtracking may require different handling than one due to graph_depth.
Example:
Suppose the following list of relationships:
Alice -> Bob, Debra
Bob -> Carl
Carl -> Debra
Debra -> Eustice
Using the graph traversal system I currently employ, after three recursions the Bob branch would be:
Alice -> Bob -> Carl -> Debra
If the max_depth was set to 3, we would not query for Debra's relationships, but we would add her to the cache.
The problem occurs when we exit Bob's recursion stack, return to iterating over Alice's friends, and re-encounter Debra.
At this stage, Debra is skipped due to being in the cache. So despite being well within the specified graph depth, we would never build up the other branch under Alice:
Alice -> Debra -> Eustice
Reminder to self: the keyword here was "due to graph_depth". The unit test I wrote yesterday had a high depth. Reduce that to get the expected test failure.
When I was working on traversing the graph I ran into some issues in the recursion. First among these was recursing over already-queried Players (who had also been appended into the player_cache). My naive solution to this was first to add a second parameter into the recursion function to allow checking for backtracking. I then determined I could simplify this by using player_cache. I now believe this may have been a mistake. The reason: a Player skipped due to backtracking may require different handling than one due to graph_depth.
Example:
Suppose the following list of relationships: Alice -> Bob, Debra Bob -> Carl Carl -> Debra Debra -> Eustice
Using the graph traversal system I currently employ, after three recursions the Bob branch would be: Alice -> Bob -> Carl -> Debra
If the max_depth was set to 3, we would not query for Debra's relationships, but we would add her to the cache.
The problem occurs when we exit Bob's recursion stack, return to iterating over Alice's friends, and re-encounter Debra.
At this stage, Debra is skipped due to being in the cache. So despite being well within the specified graph depth, we would never build up the other branch under Alice: Alice -> Debra -> Eustice