ENH: pre-compute neighbor information when dijkstra distance is used
RF: use @with_tempfile wherever possible