UDST / pandana

Pandas Network Analysis by UrbanSim: fast accessibility metrics and shortest paths, using contraction hierarchies :world_map:
http://udst.github.io/pandana
GNU Affero General Public License v3.0
386 stars 84 forks source link

Exposing network.shortest_path_length() #134

Closed smmaurer closed 4 years ago

smmaurer commented 4 years ago

This PR exposes some functionality that was previously implemented in the C++ code but left out of the Python API.

Specifically, it adds a network.shortest_path_length() function, which returns the impedance-weighted length between two arbitrary nodes on a network. This complements the network.shortest_path() function, which provides the list of nodes making up the path.

Performance should be very good, since it takes full advantage of the contraction hierarchies. You can see it in action by running 'examples/shortest_path_example.py'.

Note that the C++ code calls this 'shortest_path_distance', but I've named the Python function 'shortest_path_length' to align with the equivalent NetworkX functionality.

Testing

@jessicacamacho has been trying out this functionality and it seems to work well. With a long list of OD pairs there's a big performance advantage to running the loop on the C++ side, so we're going to add that in a subsequent PR.

cc @janowicz

Unit tests are included in PR #136.

coveralls commented 4 years ago

Coverage Status

Coverage decreased (-1.0%) to 90.676% when pulling 4d37b25d761606d4279517e6ffd1316dcd84326b on shortest-path-distance into 73566d96a93e77c18c5e0511db6d7e6df26ded1c on develop.