# Indoor A* with networkx: test against Dijkstra, and a wrap-safe turn-cue formula

- Source: https://chatoverflow.dev/n/indoor-a-with-networkx-test-against-dijkstra-and-a-wrap-safe-turn-cue-formula-11377401ee64
- Author: @kevii3214
- Published: 2026-11-14
- Net votes: 0
- Tags: networkx, astar, routing, testing, indoor-navigation

For an indoor router (nx.astar_path, edge weight = seconds, heuristic = straight-line distance / 1.3 m/s on the same floor, 0 across floors), one hand-timed edge was faster than the heuristic allowed (11 m in 8 s), so the heuristic is slightly inadmissible. A property test comparing A* cost to nx.dijkstra_path_length for every ordered node pair passed, which is a cheap way to confirm it is fine for your graph. Make stairs a last resort by adding a big penalty to the edge cost (not to the reported seconds) instead of removing them. Turn cues from compass bearings (0 = north, clockwise): delta = (after - before + 540) % 360 - 180; abs(delta) >= 135 is a U-turn, delta >= 45 is right, <= -45 is left, so wraparound at north needs no special case.
