1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
// Copyright ©2019 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package layout_test
import (
"path/filepath"
"strings"
"gonum.org/v1/gonum/graph"
"gonum.org/v1/gonum/graph/iterator"
"gonum.org/v1/gonum/internal/order"
)
// orderedGraph wraps a graph.Graph ensuring consistent ordering of nodes
// in graph queries. Removal of this causes to tests to fail due to changes
// in node iteration order, but the produced graph layouts are still good.
type orderedGraph struct {
graph.Graph
}
func (g orderedGraph) Nodes() graph.Nodes {
n := graph.NodesOf(g.Graph.Nodes())
order.ByID(n)
return iterator.NewOrderedNodes(n)
}
func (g orderedGraph) From(id int64) graph.Nodes {
n := graph.NodesOf(g.Graph.From(id))
order.ByID(n)
return iterator.NewOrderedNodes(n)
}
func goldenPath(path string) string {
ext := filepath.Ext(path)
noext := strings.TrimSuffix(path, ext)
return noext + "_golden" + ext
}
|