-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
43 lines (30 loc) · 1.23 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"testing"
)
func TestRemoveBadeNode(t *testing.T) {
graph := [][]int{{1, 0, 0, 0}, {0, 1, 1, 1}, {1, 1, 1, 1}, {0, 1, 1, 1}}
t.Logf("origin: %v \n", graph)
t.Logf("result: %v \n", removeBadNodeConnection(graph, 3))
}
func TestFindOutGoodNodeCount(t *testing.T) {
graph := [][]int{{1, 0, 0, 0}, {0, 1, 1, 1}, {0, 1, 1, 1}, {0, 1, 1, 1}}
t.Logf("origin: %v \n", graph)
t.Logf("result: %v \n", findOutGoodNodeCount(graph, []int{1}))
graph = [][]int{{1, 1, 0}, {1, 1, 0}, {0, 0, 1}}
t.Logf("origin: %v \n", graph)
t.Logf("result: %v \n", findOutGoodNodeCount(graph, []int{0, 1}))
graph = [][]int{{1, 1, 0}, {1, 1, 1}, {0, 1, 1}}
t.Logf("origin: %v \n", graph)
t.Logf("result: %v \n", findOutGoodNodeCount(graph, []int{0, 1}))
graph = [][]int{{1, 1, 0, 0}, {1, 1, 1, 0}, {0, 1, 1, 1}, {0, 0, 1, 1}}
t.Logf("origin: %v \n", graph)
t.Logf("result: %v \n", findOutGoodNodeCount(graph, []int{0, 1}))
}
func TestMinMalwareSpread(t *testing.T) {
graph := [][]int{{1, 1, 0, 0}, {1, 1, 1, 0}, {0, 1, 1, 1}, {0, 0, 1, 1}}
bigestGoodNodeCountByremovedBadNode := minMalwareSpread(graph, []int{0, 1})
for k, v := range bigestGoodNodeCountByremovedBadNode {
t.Logf("goodNodeCount: %v removeBadNode: %v \n", k, v)
}
}