-
Notifications
You must be signed in to change notification settings - Fork 1
/
eulerIntegration_test.go
64 lines (59 loc) · 1.05 KB
/
eulerIntegration_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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package comptop
import "testing"
// Simplicial Complex of sensor network
// ************************************
// Vertex Labels for simplicial complex X:
//
// 0----1----2
// \ / \ /
// 3-----4
// / \ / \
// 5----6----7
// \ / \ /
// 8-----9
// / \ / \
// 10---11---12
//
// Height function values h(x):
//
// 1----3----1
// \ / \ /
// 2-----2
// / \ / \
// 0----0----0
// \ / \ /
// 0-----1
// / \ / \
// 0----1----1
//
// Euler Integral:
//
// /-\
// |
// | h(x) d\/ = 4
// | /\
// \-/
//
func TestEulerIntegral(t *testing.T) {
c := &Complex{}
b := []Base{
{0, 1, 3}, {1, 3, 4}, {1, 2, 4},
{3, 5, 6}, {3, 4, 6}, {4, 6, 7},
{5, 6, 8}, {6, 8, 9}, {6, 7, 9},
{8, 10, 11}, {8, 9, 11}, {9, 11, 12},
}
c.NewSimplices(b...)
data := map[Index]int{
0: 1, 1: 3, 2: 1,
3: 2, 4: 2,
5: 0, 6: 0, 7: 0,
8: 0, 9: 1,
10: 0, 11: 1, 12: 1,
}
f := CF(func(idx Index) int {
return data[idx]
})
if a := c.EulerIntegral(0, 3, f); a != 4 {
t.Fatalf("expected 4 targets, counted: %d", a)
}
}