mirror of
https://github.com/gonum/gonum.git
synced 2025-10-30 02:02:09 +08:00
graph: add Empty universal iterator for empty returns
This commit is contained in:
@@ -169,7 +169,7 @@ func (g *Grid) NodeAt(r, c int) graph.Node {
|
||||
// ends of an edge must be open.
|
||||
func (g *Grid) From(uid int64) graph.Nodes {
|
||||
if !g.HasOpen(uid) {
|
||||
return nil
|
||||
return graph.Empty
|
||||
}
|
||||
nr, nc := g.RowCol(uid)
|
||||
var to []graph.Node
|
||||
@@ -180,6 +180,9 @@ func (g *Grid) From(uid int64) graph.Nodes {
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(to) == 0 {
|
||||
return graph.Empty
|
||||
}
|
||||
return iterator.NewOrderedNodes(to)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user