gonum / graph

Graph packages for the Go language [DEPRECATED]
250 stars 39 forks source link

Failing search #159

Closed saulshanabrook closed 8 years ago

saulshanabrook commented 8 years ago

How do I know if a path search (like AStar) failed? It returns a path.Shortest struct, but I don't know how to tell if that is a valid path or just a dummy one it returned.

saulshanabrook commented 8 years ago

the To method will return math.Inf(1) as the weight if it is unreachable

kortschak commented 8 years ago

It's worth looking at what path.Shortest and path.AllShortest actually hold. They are not holding just the single shortest path (trivially obvious in the latter case), but all paths from the source (or all nodes) to all destinations. Since we are keeping this, it's a necessary consequence that we report when a part is not possible.