Tremaux's algorithmObviously you don't have to mark directly on the street, you could just keep track of things on a map (or maybe you have a really good memory . . . ).
Tremaux's algorithm is an efficient method to find the way out of a maze that requires drawing a line on the floor to mark a path, and is guaranteed to work for all mazes that have well-defined passages. On arriving at a junction, pick a direction and mark it and the direction you came from. When arriving at a marked junction pick an unmarked passage if possible. If it is not possible to pick an unmarked passage take a marked one, marking it again (you can pick the path you came from). Never pick a twice marked path, where you will never need to take any passage more than twice. If there is no exit, this method will take you back to the start.
You are not logged in, either login or create an account to post comments
This is unlikely to be the case; you probably have a bunch of intersections where an odd number of streets you need to traverse meet. Get a map of the area you need to cover, and mark all such intersections. Now, pair up those odd intersections in such a way that the total driving distance between the paired intersections is minimized. (This is the hard part, but if the number is small enough, you may be able to brute-force it. Or you may be able to eyeball it if you don't absolutely need the best possible route but merely a pretty good one.) The routes between those pairs of intersections are the streets you'll be driving on twice—you've now converted your non-Eulerian graph to a Eulerian one by doubling some of the routes, in a way that minimizes the total distance.
posted by DevilsAdvocate at 2:35 PM on January 14