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

Function TestDfsWhenPathIsFound

graph/depthfirstsearch_test.go:8–35  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6)
7
8func TestDfsWhenPathIsFound(t *testing.T) {
9 nodes := []int{
10 1, 2, 3, 4, 5, 6,
11 }
12
13 //Adjacency Matrix for connected nodes
14 edges := [][]bool{
15 {false, true, true, false, false, false},
16 {true, false, false, true, false, false},
17 {true, false, false, true, false, false},
18 {false, true, true, false, true, false},
19 {false, false, false, true, false, true},
20 {false, false, false, false, true, false},
21 }
22
23 start := 1
24 end := 6
25
26 actual, actualIsFound := DepthFirstSearch(start, end, nodes, edges)
27 expected := []int{1, 3, 4, 5, 6}
28 expectedIsFound := true
29 t.Run("Test Dfs", func(t *testing.T) {
30 if !reflect.DeepEqual(expected, actual) || !reflect.DeepEqual(actualIsFound, expectedIsFound) {
31 t.Errorf("got route: %v, want route: %v", actual, expected)
32 t.Errorf("got isFound: %v, want isFound: %v", actualIsFound, expectedIsFound)
33 }
34 })
35}
36
37func TestDfsWhenPathIsNotFound(t *testing.T) {
38 nodes := []int{

Callers

nothing calls this directly

Calls 1

DepthFirstSearchFunction · 0.85

Tested by

no test coverage detected