Travelling trees


Hi all,

I have made a program, which generates mazes, and I’m stuck when trying to count the steps from node to node. To be clear, I can generate the nodes, but I cannot count the lengths of the paths in between the nodes.

To generate the maze I utilize a method which checks the neighbours to see if they have been visited, if it hasnt it returns the cell, and repeats the process until it runs out of non visited cells, at which point it uses a stack to travel back.

Now I thought the travel node problem would be fairly similar, however I cannot use the visited/non visited method, as I’m trying to check all nodes at once and not individually, for time saving purposes. The problem with this method is that if two separate nodes are connected, then the function will meet in the middle of the path and only provide half the length, or possibly slightly less or slightly more.

1 Like

solution found, sketch updated.