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

@@ -140,7 +140,9 @@ func (lt *lengauerTarjan) dfs(g graph.Directed, v graph.Node) {
ltv.label = ltv
lt.nodes = append(lt.nodes, ltv)
for _, w := range graph.NodesOf(g.From(v.ID())) {
to := g.From(v.ID())
for to.Next() {
w := to.Node()
wid := w.ID()
idx, ok := lt.indexOf[wid]

View File

@@ -162,7 +162,9 @@ func (lt *sLengauerTarjan) dfs(g graph.Directed, v graph.Node) {
ltv.label = ltv
lt.nodes = append(lt.nodes, ltv)
for _, w := range graph.NodesOf(g.From(v.ID())) {
to := g.From(v.ID())
for to.Next() {
w := to.Node()
wid := w.ID()
idx, ok := lt.indexOf[wid]