TaipanRex / pyvisgraph

Given a list of simple obstacle polygons, build the visibility graph and find the shortest path between two points
MIT License
217 stars 45 forks source link

shortest_path when two solutions, issue with Python 3 and heapq #22

Closed TaipanRex closed 7 years ago

TaipanRex commented 7 years ago

If there are two points of equal distance, the priority in the priority_dict will be same. heapq will then revert to the next value (which are the Points themselves) and try and compare. Point does not have a lt (or a cmp for that matter, so not sure why this isnt a problem in Python2) and it raises a ValueError as Points are not comparable.

A quick fix is to add a lt to Point class, and just compare their hash. This way its kind of random which solution is chosen.