Debian Codegraph @

bfs_test.go

raw symbols SCIP
1 package graph
2
3 import (
4 "strconv"
5 "testing"
6 )
7
8 func TestBFS(t *testing.T) {
9 g := New(10)
10 for _, e := range []struct {
11 v, w int
12 }{
13 {0, 1}, {0, 4}, {0, 7}, {0, 9},
14 {4, 2}, {7, 5}, {7, 8},
15 {2, 3}, {5, 6},
16 {3, 6}, {8, 9}, {4, 4},
17 } {
18 g.AddBoth(e.v, e.w)
19 }
20 exp := "0147925836"
21 res := "0"
22 BFS(Sort(g), 0, func(v, w int, c int64) {
23 res += strconv.Itoa(w)
24 })
25 if mess, diff := diff(res, exp); diff {
26 t.Errorf("BFS: %s", mess)
27 }
28 }