Mapping an unfamiliar area using "human depth-first search"

I’d like to share a simple method for recording GPX tracks of unfamiliar areas outdoors. Suppose you’d like to walk an area under the following constraints:

  • You’d like to finish at the exact point you started.
  • You’d like to travel each path exactly twice to improve accuracy. Because GNSS/GPS data is inherently inaccurate.
  • You don’t want to travel any extra distance.
  • You’re in the field, so you want to keep things simple.

Here’s an animation:

dfs

  • First view: The final mapping.
  • Second view: The route I walked (the GPX track).
  • Third view: An animation to illustrate the algorithm. A red highlight means a path was traveled for the first time. A de-highlight means the path was traveled a second time.

So what’s happening here? To travel the paths of an unfamiliar area exactly twice and then finish where you started, here is what you should do.

Intuitive instructions

Start anywhere, and travel in any direction you choose.

Step A - Explore: Imagine you’re leaving breadcrumbs or laying a piece of rope along the route. Keep traveling until reaching a dead end, or until reaching a junction you already visited, (the rope touches itself. in the animation, this happens at the dashed green paths). Now go to step B.

Step B - backtrack: Travel back the path you came from to the previous junction, unfolding the rope or removing the breadcrumbs in the process. When reaching the previous junction, pick any untraveled path and go back to step A. If you have no untraveled paths to choose from at this junction, repeat step B instead! (Keep traveling back the path you came from).

You finish once the entire rope has been unfolded or all of the breadcrumbs are removed. Now you have 2 readings of each path and you’re exactly where you started.

I personally use OSMand to track my breadcrumbs. I pin a flag at each path I travel in step A, close to the junction I just arrived at. Alternatively, you can just memorize your breadcrumbs or use physical breadcrumb-like markers.

You can do this process twice to obtain 4 readings of each path!

Full algorithm

If you prefer precise instructions, here’s the full algorithm. Computer-savvy people may recognize this algorithm as an online traversal of a Spanning Tree, with a tiny variation: the dashed lines, which are paths that aren’t part of the spanning tree, are traveled too, but then one encounters an already visited vertex and immediately turns back.

Begin: A vertex is a junction or the end of a path. Start at any vertex.

A. You are standing at a vertex. Do the following:

  • If there are untravelled paths:
    • pick one at random, travel it until reaching the next vertex.
    • If this is your first time at this new vertex, mark the path you just traveled as the PARENT of the new vertex.
    • Otherwise, if this vertex has been visited before, travel back to the vertex you just came from.
    • Repeat the instructions starting from (A).
  • If there are no untraveled paths:
    • It’s time to backtrack; Recall the vertex’s PARENT path and travel it until reaching a vertex. Repeat the instructions starting from A.
    • If there is no PARENT path, you must be at the starting point. You’ve completed the task!
11 Likes

I added a more intuitive explanation.

Sounds like this could be useful in the MOROW app project. My diary entry here: