graph: use iterators directly rather than copying into []graph.Node

There are still uses in test code; these can remain since they simplify
that code.
This commit is contained in:
Dan Kortschak
2020-06-06 11:20:54 +09:30
parent 91d83a4f35
commit 2bf857dc70
10 changed files with 57 additions and 22 deletions

View File

@@ -48,7 +48,9 @@ func BellmanFordFrom(u graph.Node, g graph.Graph) (path Shortest, ok bool) {
uid := u.ID()
j := path.indexOf[uid]
for _, v := range graph.NodesOf(g.From(uid)) {
to := g.From(uid)
for to.Next() {
v := to.Node()
vid := v.ID()
k := path.indexOf[vid]
w, ok := weight(uid, vid)