Routeem / README.md
3hstack's picture
Upload 3 files
8f17b5a verified
|
Raw History Blame Contribute Delete
2.44 kB
metadata
title: Route Em
emoji: 🗺️
colorFrom: blue
colorTo: indigo
sdk: docker
app_port: 7860
pinned: false
license: mit

Route Em

Finds the shortest closed route that covers every road, both sides — the route you'd drive or walk to put a paper on every doorstep.

How to use it

  1. Drop your map screenshot in the left panel. It stays in your browser — it's never uploaded. It's a visual reference for matching the map.
  2. Type a ZIP code or address and hit Find. The map jumps there.
  3. Click "Draw box" and drag a rectangle around the neighborhood.
  4. Optional: shift-click to set where you start and end.
  5. Solve route.

You get the route drawn in travel order (blue → yellow), deadhead segments dashed red, plus total distance, deadhead miles, efficiency, and turn-by-turn directions.

Why it's optimal, not a guess

This is the Directed Chinese Postman Problem:

  • Two-way street → two required passes (one per curb).
  • One-way street → one required pass.
  • Find the shortest closed walk covering every required pass.

Solved exactly:

  1. Compute each intersection's imbalance (out_degree − in_degree).
  2. Min-cost flow from deficit nodes to surplus nodes, cost = shortest-path distance. This yields the cheapest set of passes to repeat ("deadhead").
  3. Add those repeats — the graph is now Eulerian — and extract the Eulerian circuit.

That circuit is provably the shortest possible. The solver asserts full coverage before returning anything.

Notes

  • Roads come from OpenStreetMap via Overpass. Coverage is only as good as OSM's data for your area — check for missing new streets.
  • Areas are capped at 25 sq mi / 6,000 passes. A real paper route is well under 1 sq mi.
  • Deadhead mileage is unavoidable, not a flaw — cul-de-sacs and dead ends force backtracking by definition.
  • Time estimates use crude constants (12 mph driving, 2.5 mph walking, stops included).
  • This Space calls the public Overpass and Nominatim APIs. On a shared IP they occasionally rate-limit; if a solve fails, wait a moment and retry.

Deploy your own

git clone https://huggingface.co/spaces/<you>/route-em
cd route-em
# copy app.py, Dockerfile, README.md in  (deps are inlined in the Dockerfile)
git add . && git commit -m "Route Em" && git push

The Space builds itself from the Dockerfile. First build takes a few minutes (geopandas).