frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Show HN: US Routing – Python library for fast local routing in the US

https://github.com/ivanbelenky/us-routing
114•ivanbelenky•7mo ago

Comments

dmitrygr•7mo ago
Routing library, having nothing to do with Google or Google maps.
ivanbelenky•7mo ago
does that account for 1% of gmaps functionality?
simonw•7mo ago
From poking around in the source code I found this 282M SQLite database:

  wget https://services.arcgis.com/xOi1kZaI0eWDREZv/arcgis/rest/services/NTAD_North_American_Roads/FeatureServer/replicafilescache/NTAD_North_American_Roads_3862439624850511818.geodatabase
I can't figure out how to read it though. I get this error:

  Connection to NTAD_North_American_Roads_3862439624850511818.geodatabase failed check: no such module: VSRS
As far as I can tell VSRS is a proprietary Esri thing.
ivanbelenky•7mo ago
"This NTAD dataset is a work of the United States government as defined in 17 U.S.C. § 101 and as such are not protected by any U.S. copyrights. This work is available for unrestricted public use."

I based my work on this, maybe the link is out, thx for testing. The dataset has already been consumed and collapsed into a smaller graph representation.

Centigonal•7mo ago
if you follow the link in the github readme, there are a few other download options for the dataset, like CSV or shapefile
jdelman•7mo ago
It's kinda nice to see a non-AI project on here.
zeckalpha•7mo ago
Graph traversal is a classical AI problem. See Ch. 3 from AIMA: https://aima.cs.berkeley.edu/index.html

I assume you mean non-LLM.

OutOfHere•7mo ago
Graph transformers, using the same technology as in LLMs, have been a topic of research for many years, also for routing problems. So yes, it is non-LLM, but they could still have a lot in common.
svcphr•7mo ago
Nice. Very light-weight compared to proper local routers like Graphhopper, OSRM, etc., which can be overkill for simple tasks. Although the 'routing' here is nx.shortest_path, which is just Dijkstra, so pretty slow compared to other easy to implement routing algorithms (even just bi-directional Dijkstra or A*... although contraction hierarchies would be huge gain here since edge weights are fixed). Also not sure why readme describes it as an approximation? Dijkstra is guaranteed to return lowest cost path. Maybe approximation because assuming free-flow, or if the NAR dataset is incomplete?
ivanbelenky•7mo ago
Thx for the heads up on optimizations available. The “Approximations” comment does not apply to the shortest path calculation, but rather to the distances and upper bound times estimations. This is the consequence of enabling routing for points that dont exist as nodes (closest node approximation).
shoo•7mo ago
> Although the 'routing' here is nx.shortest_path, which is just Dijkstra, so pretty slow compared to other easy to implement routing algorithms

networkx has advantages of being popular, well-documented, pure python (less hassle to maintain) with code that is easy to read and modify. but, one big downside of being pure python means that it also has fundamentally poor performance: it can't use a cpu efficiently, the way the graphs are represented also means it can't use memory, memory bandwidth or cache efficiently either.

orthogonally from switching the search algorithm, one quick way to potentially get a large speedup is try swapping out networkx for rustworkx (or any other graph library with python bindings that has native implementations of data structures and graph algorithms)

another thing to check would be to avoid storing auxiliary node/edge attributes in the graph that aren't necessary during search, so that cache and memory bandwidth can be focused on node indices and edge weights.

I went down a rabbit hole playing around with this some years ago (using Cython not rust). Relatively simple things like "store the graph in an array-oriented way (CSC/CSR sparse matrix format or similar)" and "eliminate all memory allocation and pure python code from the Dijkstra search, replace it with simple C code using indices into preallocated arrays" gets you pretty far. It is possible to get further performance increases by reviewing and tweaking the search code to avoid unnecessary branches, investigating variants of the priority queue used to maintain partial paths by path distance (i found switching the heap queue from a binary tree to a 4-ary tree gave a 30% reduction in running time), seeing if the nodes of the graph can be reindexed so that nodes with similar indices are spatially similar and more likely to be in cache (another 30% or so reduction in running time from Hilbert curve ordering). Some of this will be quite problem and data dependent and not necessarily a good tradeoff for other graphs. All up I got around a 30x speedup vs baseline networkx for dijkstra searches to compute path distances to all nodes from a few source nodes on a street network graph with 3.6m nodes & 3.8m edges (big enough not to fit in L3 cache for the CPU i was running experiments with).

karussell•7mo ago
What does light-weight mean in this case? Less data? Ease of installation?
CamperBob2•7mo ago
Edit: thanks very much for the suggestions, especially adding the Python version to the uv command line. I totally missed that, and that totally fixed it. Apologies for the OT tech support derailment.

--------------

Question for those familiar with uv. US Routing apparently requires a very specific Python version (3.11 and nothing else), but my system has Python 3.10.9 installed at the moment and I'd rather not upgrade the global version just now. My understanding from reading a lot of uv evangelism on HN and elsewhere is that uv fixes this type of dilemma. But, having just tried to use it to install this package, it's just giving me the same old Python version errors:

    C:\devel\us-routing-master\us_routing>uv venv
    Using CPython 3.10.9 interpreter at: c:\WinPython-31090
    \python-3.10.9.amd64\python.exe
    Creating virtual environment at: .venv
    Activate with: .venv\Scripts\activate

    C:\devel\us-routing-master\us_routing>.venv\Scripts\activate

    (us_routing) C:\devel\us-routing-master\us_routing>uv pip     
    install us-routing

    x No solution found when resolving dependencies:
    `-> Because the current Python version (3.10.9) does not 
    satisfy Python>=3.11,<3.12 and us-routing==0.1.0
    depends on Python>=3.11,<3.12, we can conclude that us-    
    routing==0.1.0 cannot be used.
    And because only us-routing==0.1.0 is available and you 
    require us-routing, we can conclude that your
    requirements are unsatisfiable.
Am I misunderstanding the whole uv thing, or just doing something wrong? Or is us-routing somehow incompatible with it?
zerocrates•7mo ago
You just created a venv but didn't change the Python version.

I imagine you'd want:

uv venv --python 3.11

thelastbender12•7mo ago
You need to request a specific python version compatible with this project. Give `uv venv --python 3.11` a try.

https://docs.astral.sh/uv/pip/environments/

ivanbelenky•7mo ago
This is a project I did not maintain much for the past few months, but recently I migrated many other codebases to be uv managed, and I find this optimal for many reasons. Happy to receive contributions and fix the quite strict requirements I set. That would probably be the faster way.
nighthawk454•7mo ago
By the looks of things, uv is telling you it’s creating a venv with Python 3.10.9 still. Since you didn’t specify you wanted another version, it probably defaulted to the first available system version.

What you want is `uv venv —python 3.11` to create a virtual environment with Python 3.11 without messing up your global system env. This should also install a portable version of Python 3.11 if needed (which it will be since you don’t have it).

https://docs.astral.sh/uv/pip/environments/#creating-a-virtu...

mrlatinos•7mo ago
This library can use any version of Python 3.11, which you can install alongside your existing 3.10.9 without changing your global python version. I don't typically work in Windows so the codeblock below is AI generated, but follows the path I would normally take - manage installed python versions using pyenv, changing the python version only for this directory via .python_version, and then creating uv environment using that.

``` :: Step 1: Install pyenv-win (make sure Git is installed) git clone https://github.com/pyenv-win/pyenv-win.git "$env:USERPROFILE\.pyenv"

:: Step 2: Add pyenv to PATH (run or add to your profile) $env:PYENV = "$env:USERPROFILE\.pyenv\pyenv-win" $env:PATH += ";$env:PYENV\bin;$env:PYENV\shims"

:: Step 3: Restart your terminal or reload environment if needed :: (you can paste the above $env:... lines again after restart)

:: Step 4: Install Python 3.11 pyenv install 3.11.9

:: Step 5: Set the local Python version for your project folder cd C:\devel\us-routing-master\us_routing pyenv local 3.11.9

:: Step 6: Verify correct Python is selected pyenv which python # should point to 3.11.x

:: Step 7: Create uv environment using Python 3.11 uv venv .venv --python "$(pyenv which python)"

:: Step 8: Activate the environment .venv\Scripts\activate

:: Step 9: Install your package uv pip install us-routing ```

pyenv is a great way to have many versions of Python installed, whether or not your global is mapped to the latest. You don't even need to set the local .python_version.. you could just do `uv venv .venv --python=python3.11`

protocolture•7mo ago
Came here to complain about US Telcos being willing to do anything other than enabling dynamic routing.

Glad to see this is for roads.

VladVladikoff•7mo ago
Does it work for shorter distances? within a city from one business to another address?
ivanbelenky•7mo ago
it can be extended arbitrary given the proper dataset. For the current default settings, road class covers everything below 3. This translates to

FREEWAY = 1 # Freeway (Multi-lane, controlled access)

PP_TH = 2 # Primary Provincial/Territorial highway

SP_TH_MA = 3 # Secondary Provincial/territorial highway/ municipal arterial

MC_USP_TH = 4 # Municipal collector/Unpaved secondary provincial/territorial highway

LS_WR = 5 # Local street/ winter road

3 was the sweetspot. The dataset can be explored here in case you want to get an intuition on detail level. https://geodata.bts.gov/datasets/usdot::north-american-roads...

culopatin•7mo ago
I’d love to see if I could assist in adding road type filters such as avoid multi lane highways for example
ivanbelenky•7mo ago
Contributions are welcomee!!
django-john•7mo ago
Nice. Clean and lightweight compared to full routing stacks like OSRM or Graphhopper, which can be a bit much for smaller/local tasks. Curious why the README calls it an "approximation" though — Dijkstra gives exact shortest paths unless you're simplifying inputs. Maybe that's referring to free-flow assumptions or limitations in the underlying network data? Still, cool to see a focused US-only tool.
schemathings•7mo ago
The feature I always wish for with nav software is 'go back the same way'.
dbatten•7mo ago
If you find this interesting, definitely consider checking out contraction hierarchies. One of the early algorithms used by mapping software to enable calculating fastest routes between any pair of places. It's exact, and it's orders of magnitude faster than graph search algorithms like Dijkstra.

This webpage has a very intuitive graphical explanation of how it works: https://www.mjt.me.uk/posts/contraction-hierarchies/

(I had the joy of implementing this in Python with OSM data a few years ago. Planning a three hour car trip with software I wrote and having it come back with the same path recommended by Google Maps in a matter of milliseconds was a very rewarding feeling.)

The ancient monuments saluting the winter solstice

https://www.bbc.com/culture/article/20251219-the-ancient-monuments-saluting-the-winter-solstice
61•1659447091•4h ago•41 comments

The biggest CRT ever made: Sony's PVM-4300

https://dfarq.homeip.net/the-biggest-crt-ever-made-sonys-pvm-4300/
9•giuliomagnifico•49m ago•1 comments

If you don't design your career, someone else will (2014)

https://gregmckeown.com/if-you-dont-design-your-career-someone-else-will/
163•TheAlchemist•3h ago•86 comments

BMW Patents Proprietary Screws That Only Dealerships Can Remove

https://carbuzz.com/bmw-roundel-logo-screw-patent/
49•thunderbong•4h ago•33 comments

A guide to local coding models

https://www.aiforswes.com/p/you-dont-need-to-spend-100mo-on-claude
470•mpweiher•16h ago•259 comments

Programming languages used for music

https://timthompson.com/plum/cgi/showlist.cgi?sort=name&concise=yes
91•ofalkaed•1d ago•25 comments

Show HN: Netrinos – A keep it simple Mesh VPN for small teams

https://netrinos.com
7•pcarroll•2d ago•5 comments

A year of vibes

https://lucumr.pocoo.org/2025/12/22/a-year-of-vibes/
18•lumpa•3h ago•1 comments

Deliberate Internet Shutdowns

https://www.schneier.com/blog/archives/2025/12/deliberate-internet-shutdowns.html
222•WaitWaitWha•3d ago•101 comments

Well being in times of algorithms

https://www.ssp.sh/blog/well-being-algorithms/
25•articsputnik•3h ago•16 comments

Show HN: Jordle – Japanese Furigana Practice

https://jordle.io
5•qmarchi•5d ago•0 comments

Show HN: Books mentioned on Hacker News in 2025

https://hackernews-readings-613604506318.us-west1.run.app
503•seinvak•21h ago•179 comments

I announced my divorce on Instagram and then AI impersonated me

https://eiratansey.com/2025/12/20/i-announced-my-divorce-on-instagram-and-then-ai-impersonated-me/
90•robin_reala•6h ago•78 comments

I'm just having fun

https://jyn.dev/i-m-just-having-fun/
406•lemper•6d ago•170 comments

Webb observes exoplanet that may have an exotic helium and carbon atmosphere

https://science.nasa.gov/missions/webb/nasas-webb-observes-exoplanet-whose-composition-defies-exp...
80•taubek•3d ago•20 comments

Disney Imagineering Debuts Next-Generation Robotic Character, Olaf

https://disneyparksblog.com/disney-experiences/robotic-olaf-marks-new-era-of-disney-innovation/
216•ChrisArchitect•15h ago•89 comments

Build Android apps using Rust and Iced

https://github.com/ibaryshnikov/android-iced-example
116•rekireki•11h ago•40 comments

Debian's Git Transition

https://diziet.dreamwidth.org/20436.html
20•all-along•5h ago•1 comments

Cartoon Network channel errors (1995 – 2025)

https://cnas.fandom.com/wiki/Channel_Errors
26•Pikamander2•4h ago•5 comments

Kernighan's Lever

https://linusakesson.net/programming/kernighans-lever/index.php
77•xk3•2d ago•31 comments

Aliasing

https://xania.org/202512/15-aliasing-in-general
51•ibobev•6d ago•10 comments

Inverse Parentheses

https://kellett.im/a/inverse-parentheses
51•mighty-fine•5h ago•42 comments

Show HN: Backlog – a public repository of real work problems

https://www.worldsbacklog.com/
35•anticlickwise•5h ago•9 comments

Functional Flocking Quadtree in ClojureScript

https://www.lbjgruppen.com/en/posts/flocking-quadtrees
67•lbj•6d ago•4 comments

CO2 batteries that store grid energy take off globally

https://spectrum.ieee.org/co2-battery-energy-storage
280•rbanffy•22h ago•236 comments

How I protect my Forgejo instance from AI web crawlers

https://her.esy.fun/posts/0031-how-i-protect-my-forgejo-instance-from-ai-web-crawlers/index.html
63•todsacerdoti•22h ago•42 comments

Decompiling the Synergy: Human–LLM Teaming in Reverse Engineering [pdf]

https://www.zionbasque.com/files/papers/dec-synergy-study.pdf
5•matt_d•4d ago•0 comments

Rue: Higher level than Rust, lower level than Go

https://rue-lang.dev/
178•ingve•16h ago•145 comments

More on whether useful quantum computing is “imminent”

https://scottaaronson.blog/?p=9425
104•A_D_E_P_T•16h ago•84 comments

A Guide to Magnetizing N48 Magnets in Ansys Maxwell

https://blog.ozeninc.com/resources/from-datasheet-to-demagnetization-a-guide-to-magnetizing-n48-m...
42•peter_d_sherman•5d ago•5 comments