Suppose i want to check if my position is enclosed in a closed loop by following the connection of waypoints that surround it:
Now if i travel from node 0 to node 1. I'm at node 1 and i need to find the next connection of which as you can see i have multiple choices this time.
I can rule out where i came from quite easily, but that still leaves me with other options. How can I optimally pick which connection to follow next based on knowing that the connection from node 1 to node 2 is the only allowed option here anyway since as it's an enclosed loop you can consider them equivalent to being walls. I just am not sure how to check which is the most viable choice next logically speaking.
If node 1 to node 2 connection didn't exist, naturally the first logical choice would be to just go straight on ahead which is easy to tell visually just not so easy when thinking in code.