-
Notifications
You must be signed in to change notification settings - Fork 2
/
interfaces.go
87 lines (71 loc) · 1.63 KB
/
interfaces.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package lattice
import (
"io"
)
import (
"github.com/timtadh/data-structures/types"
)
type Lattice struct {
V []Node
E []Edge
Kids [][]*Edge
}
type Input func() (reader io.Reader, closer func())
type Loader interface {
Load(input Input) (DataType, error)
}
type DataType interface {
Root() Node
LargestLevel() int
MinimumLevel() int
Support() int
Acceptable(Node) bool
TooLarge(Node) bool
Close() error
}
type Node interface {
Pattern() Pattern
AdjacentCount() (int, error)
Parents() ([]Node, error)
ParentCount() (int, error)
Children() ([]Node, error)
ChildCount() (int, error)
CanonKids() ([]Node, error)
Maximal() (bool, error)
Lattice() (*Lattice, error)
}
type Pattern interface {
types.Hashable
Label() []byte
Level() int
Distance(Pattern) float64
}
type Formatter interface {
FileExt() string
PatternName(Node) string
Pattern(Node) (string, error)
Embeddings(Node) ([]string, error)
FormatPattern(io.Writer, Node) error
FormatEmbeddings(io.Writer, Node) error
PrFormatter() PrFormatter
}
type PrFormatter interface {
Matrices(Node) (matrices interface{}, err error)
CanComputeSelPr(n Node, matrices interface{}) bool
SelectionProbability(n Node, matrices interface{}) (float64, error)
FormatMatrices(w io.Writer, fmtr Formatter, n Node, matrices interface{}) error
}
type NoLattice struct{}
func (n *NoLattice) Error() string {
return "No Lattice Function Implemented"
}
type Edge struct {
Src, Targ int
}
type Embedding interface {
Components() ([]int, error)
}
type SupportMetric interface {
Supported([]Embedding) ([]Embedding, error)
}
type NodeIterator func() (Node, error, NodeIterator)