dag: require acyclic graph

This commit is contained in:
Mitchell Hashimoto 2017-02-03 11:48:09 +01:00
parent 07ce5a7624
commit 6702a22074
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
3 changed files with 9 additions and 9 deletions

View File

@ -167,7 +167,7 @@ func (g *AcyclicGraph) Walk(cb WalkFunc) error {
defer g.debug.BeginOperation(typeWalk, "").End("")
w := &Walker{Callback: cb, Reverse: true}
w.Update(&g.Graph)
w.Update(g)
return w.Wait()
}

View File

@ -135,7 +135,7 @@ func (w *Walker) Wait() error {
//
// Multiple Updates can be called in parallel. Update can be called at any
// time during a walk.
func (w *Walker) Update(g *Graph) {
func (w *Walker) Update(g *AcyclicGraph) {
var v, e *Set
if g != nil {
v, e = g.vertices, g.edges

View File

@ -9,7 +9,7 @@ import (
)
func TestWalker_basic(t *testing.T) {
var g Graph
var g AcyclicGraph
g.Add(1)
g.Add(2)
g.Connect(BasicEdge(1, 2))
@ -34,7 +34,7 @@ func TestWalker_basic(t *testing.T) {
}
func TestWalker_updateNilGraph(t *testing.T) {
var g Graph
var g AcyclicGraph
g.Add(1)
g.Add(2)
g.Connect(BasicEdge(1, 2))
@ -54,7 +54,7 @@ func TestWalker_updateNilGraph(t *testing.T) {
}
func TestWalker_error(t *testing.T) {
var g Graph
var g AcyclicGraph
g.Add(1)
g.Add(2)
g.Add(3)
@ -94,7 +94,7 @@ func TestWalker_error(t *testing.T) {
func TestWalker_newVertex(t *testing.T) {
// Run it a bunch of times since it is timing dependent
for i := 0; i < 50; i++ {
var g Graph
var g AcyclicGraph
g.Add(1)
g.Add(2)
g.Connect(BasicEdge(1, 2))
@ -130,7 +130,7 @@ func TestWalker_newVertex(t *testing.T) {
func TestWalker_removeVertex(t *testing.T) {
// Run it a bunch of times since it is timing dependent
for i := 0; i < 50; i++ {
var g Graph
var g AcyclicGraph
g.Add(1)
g.Add(2)
g.Connect(BasicEdge(1, 2))
@ -170,7 +170,7 @@ func TestWalker_removeVertex(t *testing.T) {
func TestWalker_newEdge(t *testing.T) {
// Run it a bunch of times since it is timing dependent
for i := 0; i < 50; i++ {
var g Graph
var g AcyclicGraph
g.Add(1)
g.Add(2)
g.Connect(BasicEdge(1, 2))
@ -211,7 +211,7 @@ func TestWalker_newEdge(t *testing.T) {
func TestWalker_removeEdge(t *testing.T) {
// Run it a bunch of times since it is timing dependent
for i := 0; i < 50; i++ {
var g Graph
var g AcyclicGraph
g.Add(1)
g.Add(2)
g.Add(3)