graph/path: make AllShortest safe for length zero
MODIFY
graph/path/shortest.go
graph/path/shortest.go
@@ -197,6 +197,9 @@ type AllShortest struct {
}
func newAllShortest(nodes []graph.Node, forward bool) AllShortest {
+ if len(nodes) == 0 {
+ return AllShortest{}
+ }
indexOf := make(map[int64]int, len(nodes))
for i, n := range nodes {
indexOf[n.ID()] = i

graph/path: make AllShortest safe for length zero