About the labeling order

Hello again everyone,

I have a question regarding the order (obviously). 09:40 into the lecture, Gary decides to prioritize the isPath variable over the isExplored. In lecture 133, the actual path was constructed by linking already explored nodes, FROM the destination.
Is it not contrary to the other in this here lecture?

1 Like

Great question @solideserenade!

Due to the way we’re constructing the path, the isPath and isExplored flags will both be set to true for nodes that end up being part of the path.

When it comes time to color our coordinate labels, we’re using a set of else-if statements to perform various checks on all the nodes in the grid.
These statements evaluate from top to bottom and if one happens to return true then the rest get skipped.

This means that we have to check for isPath first in our labeller. Otherwise, we would only ever see the explored nodes and not the found path.
As an experiment, try switching these two else-if statements and you’ll see that the path no longer shows up.

I hope that help.

Ooooh… I got it -_-. All node that isPath are also isExplored, which is why the isExplore must not be on top.
I gotta say I feel kinda dumb since you already said it.
Thank you for taking the time!!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms