graph/testgraph: test for missing From and To paths
MODIFY
graph/testgraph/testcases.go
graph/testgraph/testcases.go
@@ -159,6 +159,31 @@ var testCases = []struct {
absent: math.Inf(1),
},
+ {
+ name: "three in only",
+ nodes: []graph.Node{node(0), node(1), node(2), node(3)},
+ edges: []WeightedLine{
+ line{F: node(1), T: node(0), UID: 0, W: 0.5},
+ line{F: node(2), T: node(0), UID: 1, W: 0.5},
+ line{F: node(3), T: node(0), UID: 2, W: 0.5},
+ },
+ nonexist: []graph.Node{node(-1), node(4)},
+ self: 0,
+ absent: math.Inf(1),
+ },
+ {
+ name: "three out only",
+ nodes: []graph.Node{node(0), node(1), node(2), node(3)},
+ edges: []WeightedLine{
+ line{F: node(0), T: node(1), UID: 0, W: 0.5},
+ line{F: node(0), T: node(2), UID: 1, W: 0.5},
+ line{F: node(0), T: node(3), UID: 2, W: 0.5},
+ },
+ nonexist: []graph.Node{node(-1), node(4)},
+ self: 0,
+ absent: math.Inf(1),
+ },
+
{
name: "4-clique - single(non-prepared)",
edges: func() []WeightedLine {

MODIFY
graph/testgraph/testgraph.go
graph/testgraph/testgraph.go
@@ -953,6 +953,9 @@ func ReturnAdjacentNodes(t *testing.T, b Builder, useEmpty bool) {
want := make(map[edge]bool)
for _, e := range edges {
want[edge{f: e.From().ID(), t: e.To().ID()}] = true
+ if g.From(e.From().ID()).Len() == 0 {
+ t.Errorf("missing path from node %v with outbound edge %v", e.From().ID(), e)
+ }
}
for _, x := range nodes {
switch g := g.(type) {
@@ -1028,6 +1031,11 @@ func ReturnAdjacentNodes(t *testing.T, b Builder, useEmpty bool) {
t.Errorf("unexpected edge for test %q: (%v)->(%v)", test.name, u.ID(), v.ID())
}
}
+ for _, e := range edges {
+ if g.To(e.To().ID()).Len() == 0 {
+ t.Errorf("missing path to node %v with inbound edge %v", e.To().ID(), e)
+ }
+ }
case graph.Undirected:
u := x

graph/testgraph: test for missing From and To paths