Dijkstra: local search and internal data structure control #482
Replies: 2 comments
-
|
The issue is relevant for large graphs and/or time critical sensitive applications. I see two possibilities
Not sure what to advise. From a user perspective, both ways might be cumbersome. Maybe point 2 could open up a general approach to inject state to restart algorithms for instance. |
Beta Was this translation helpful? Give feedback.
-
|
To support flat_map it would be the same for map. I think it's possible to create an adaptor with specializations that presents a common interface. The specializations would exist for vector and flat_map. This is an interface change, so it might be easier to just add overloads to use it, with the consequence of doubling the number of function interfaces. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Story
addy90 runs map matching at scale: hundreds of millions of short-range Dijkstra queries over a 60M-node Germany road network. He identified two concrete performance killers.
dijkstra_shortest_paths_no_initstill allocates a full-size array. On a 60M-node graph, this single allocation dominates runtime for a search that only touches a few hundred nodes.flat_map, track only visited vertices indiscover_vertex, clean only those on reset. This reduces working memory from O(|V|) to O(search radius): huge improvement for local search.andreacassioli at Maersk has the same use case: short-range routing queries over large road networks, millions of times per day.
jcelerier (OSSIA) confirmed the same problem from a real-time audio perspective: hidden allocations inside algorithms are a correctness issue, not just a performance one.
addy90's solution:
Dream solution
Dijkstra's internal data structures are injectable via policy or template parameters. A
flat_map-backed variant exists out of the box for local searches.dijkstra_shortest_paths_no_inittruly skips all initialization including the hidden array allocation. The combination makes BGL viable for map matching, logistics routing, and any application running millions of short-range queries.Starting point
addy90's full writeup in discussion #466
jcelerier's writeup in discussion #466
dijkstra_shortest_paths.hpp line 242
dijkstra_shortest_paths.hpp line 360
Boost.Container flat_map
allocator card
Intermediary objective (45 min)
Read addy90 and jcelerier's writeups. Read the source at the links above. Then answer questions in writing:
Note that #481 covers a related problem. Make sure you are at least a bit aware of it and note conflicts or overlaps.
Beta Was this translation helpful? Give feedback.
All reactions