MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / TestBreadthFirstSearch

Function TestBreadthFirstSearch

graph/breadthfirstsearch_test.go:7–78  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5)
6
7func TestBreadthFirstSearch(t *testing.T) {
8 var bfsTestData = []struct {
9 description string
10 start int
11 end int
12 nodes int
13 edges [][]int
14 expected1 bool
15 expected2 int
16 }{
17 {
18 "test 1 connected with distance 2",
19 0,
20 5,
21 6,
22 [][]int{
23 {0, 1, 1, 0, 0, 0},
24 {1, 0, 0, 1, 0, 1},
25 {1, 0, 0, 1, 0, 0},
26 {0, 1, 1, 0, 1, 0},
27 {0, 0, 0, 1, 0, 0},
28 {0, 1, 0, 0, 0, 0},
29 },
30 true,
31 2,
32 },
33 {
34 "test 2 connected with distance 4",
35 0,
36 5,
37 6,
38 [][]int{
39 {0, 1, 1, 0, 0, 0},
40 {1, 0, 0, 1, 0, 0},
41 {1, 0, 0, 1, 0, 0},
42 {0, 1, 1, 0, 1, 0},
43 {0, 0, 0, 1, 0, 1},
44 {0, 0, 0, 0, 1, 0},
45 },
46 true,
47 4,
48 },
49 {
50 "test 2 not connected",
51 0,
52 5,
53 6,
54 [][]int{
55 {0, 1, 1, 0, 0, 0},
56 {1, 0, 0, 1, 0, 0},
57 {1, 0, 0, 1, 0, 0},
58 {0, 1, 1, 0, 1, 0},
59 {0, 0, 0, 1, 0, 0},
60 {0, 0, 0, 0, 0, 0},
61 },
62 false,
63 0,
64 },

Callers

nothing calls this directly

Calls 1

BreadthFirstSearchFunction · 0.85

Tested by

no test coverage detected