graph/{multi,simple}: fix empty To optimisation
MODIFY
graph/multi/directed.go
graph/multi/directed.go
@@ -261,7 +261,7 @@ func (g *DirectedGraph) SetLine(l graph.Line) {
// To returns all nodes in g that can reach directly to n.
func (g *DirectedGraph) To(id int64) graph.Nodes {
- if _, ok := g.from[id]; !ok {
+ if _, ok := g.to[id]; !ok {
return graph.Empty
}

MODIFY
graph/multi/weighted_directed.go
graph/multi/weighted_directed.go
@@ -270,7 +270,7 @@ func (g *WeightedDirectedGraph) SetWeightedLine(l graph.WeightedLine) {
// To returns all nodes in g that can reach directly to n.
func (g *WeightedDirectedGraph) To(id int64) graph.Nodes {
- if _, ok := g.from[id]; !ok {
+ if _, ok := g.to[id]; !ok {
return graph.Empty
}

MODIFY
graph/simple/directed.go
graph/simple/directed.go
@@ -218,7 +218,7 @@ func (g *DirectedGraph) SetEdge(e graph.Edge) {
// To returns all nodes in g that can reach directly to n.
func (g *DirectedGraph) To(id int64) graph.Nodes {
- if _, ok := g.from[id]; !ok {
+ if _, ok := g.to[id]; !ok {
return graph.Empty
}

MODIFY
graph/simple/weighted_directed.go
graph/simple/weighted_directed.go
@@ -222,7 +222,7 @@ func (g *WeightedDirectedGraph) SetWeightedEdge(e graph.WeightedEdge) {
// To returns all nodes in g that can reach directly to n.
func (g *WeightedDirectedGraph) To(id int64) graph.Nodes {
- if _, ok := g.from[id]; !ok {
+ if _, ok := g.to[id]; !ok {
return graph.Empty
}

graph/{multi,simple}: fix empty To optimisation