forked from starwander/goraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoraph_suite_test.go
58 lines (48 loc) · 1 KB
/
goraph_suite_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
// Copyright(c) 2016 Ethan Zhuang <[email protected]>.
package goraph
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestProxy(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Goraph Suite")
}
var _ = Describe("Test initialization", func() {
Context("Register suite setup and teardown function", func() {
BeforeSuite(func() {
})
AfterSuite(func() {
})
})
})
type myVertex struct {
id ID
outTo map[ID]float64
inFrom map[ID]float64
}
type myEdge struct {
from ID
to ID
weight float64
}
func (vertex *myVertex) ID() ID {
return vertex.id
}
func (vertex *myVertex) Edges() (edges []Edge) {
edges = make([]Edge, len(vertex.outTo)+len(vertex.inFrom))
i := 0
for to, weight := range vertex.outTo {
edges[i] = &myEdge{vertex.id, to, weight}
i++
}
for from, weight := range vertex.inFrom {
edges[i] = &myEdge{from, vertex.id, weight}
i++
}
return
}
func (edge *myEdge) Get() (ID, ID, float64) {
return edge.from, edge.to, edge.weight
}