Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shortest path distance between non connected nodes #168

Open
PyMap opened this issue Aug 5, 2021 · 0 comments
Open

shortest path distance between non connected nodes #168

PyMap opened this issue Aug 5, 2021 · 0 comments
Assignees

Comments

@PyMap
Copy link
Collaborator

PyMap commented Aug 5, 2021

if node exists but not connected in the net (doesn't exists in links table) pandana returns a constant distance (different from zero, 4294967.295 is the value). So Pandana is providing a shortest path length, even if shortest path returns an empty list.

image

This function matches external idx with internal ones in the net object. The shortest path method uses this function to count nodes between origin/destination here. It returns empty list, so the internal/external idx are working fine.

But, when the same operation occurs here (nodes idx are the same as shown in shortest path calculation I mention above), I get a len value for nodes involved in the empty list output. In short, I'm getting a numeric value for shortest distance when both nodes are not connected.

The shortest_path_distance calculation is call from cyacces interface (not sure but I guess here)

While creating the net object by excluding non connected nodes, the shortest path will return a ValueError: cannot convert float NaN to integer when trying to look for these internal net node indexes (here). Nodes don't exist, so shortest path can't be calculated (which is ok).

Alternatives:

  1. including a warning to declare that there are non connected nodes after the net is created
  2. adding some if statement here to discriminate distance metric as follow:
shortest_nodes = shortest_path(self, node_a, node_b, imp_name)

if len(shortest_nodes)==0:
    len=0
else:
    len = self.net.shortest_path_distance(node_a, node_b, imp_num)

(@smmaurer )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant