Skip to content

shortest path distance between non connected nodes  #168

@PyMap

Description

@PyMap

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 )

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions