-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbron-kerbosch_test.go
47 lines (31 loc) · 951 Bytes
/
bron-kerbosch_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
44
45
46
47
package main
import (
"testing"
)
func TestFindCliques(t *testing.T) {
var err error = nil
var want, eq int
// Test 1 : graph A
want = 3
allNodes := make(map[string]Node)
str_t := []string{"1", "2", "3", "4"}
for _, v := range str_t {
allNodes[v] = newNode(v)
}
allNodes["1"].neighbors["2"] = allNodes["2"]
allNodes["1"].neighbors["3"] = allNodes["3"]
allNodes["2"].neighbors["1"] = allNodes["1"]
allNodes["2"].neighbors["3"] = allNodes["3"]
allNodes["3"].neighbors["1"] = allNodes["1"]
allNodes["3"].neighbors["2"] = allNodes["2"]
allNodes["3"].neighbors["4"] = allNodes["4"]
allNodes["4"].neighbors["3"] = allNodes["3"]
potentialClique := make(map[string]Node)
skipNodes := make(map[string]Node)
var res int = 0
findCliques(potentialClique, allNodes, skipNodes, 0, &res)
eq = res
if eq != want || err != nil {
t.Fatalf(`TestFindCliques(graph_A) ; res = %d, %v, want match for %d, nil`, eq, err, want)
}
}