thcyron / graphs

Graph algorithms written in Go
https://pkg.go.dev/github.com/thcyron/graphs
MIT License
60 stars 11 forks source link

Flaky test: dfs_test.go #3

Closed gszjulcsi closed 9 years ago

gszjulcsi commented 9 years ago

The second test sometimes passes, sometimes fails. t.Errorf("should visit 5 vertices; visited %d", walks)

The stopping condition is

        if v == 5 {
            *stop = true
        }

This means that if you reach vertex 5, then the walk should terminate. It's sure that we won't seen node 6 in this case, but there is no guarantee that we have already visited node 7. It depends on go's internal ordering of map keys.

thcyron commented 9 years ago

Fixed it by testing that the following vertex 6 is not visited when stopping at 5. Thanks!