graph: don't give values to edges, that can be accomplished by a transformation layer later

This commit is contained in:
Brian Picciano 2018-08-18 14:06:43 -04:00
parent c1bdb46623
commit 9534ff5c13
2 changed files with 7 additions and 19 deletions

View File

@ -34,13 +34,13 @@ func NewValue(V interface{}) Value {
} }
// Edge is a directional edge connecting two values in a Graph, the Tail and the // Edge is a directional edge connecting two values in a Graph, the Tail and the
// Head. An Edge may also contain a value of its own. // Head.
type Edge struct { type Edge struct {
Tail, Val, Head Value Tail, Head Value
} }
func (e Edge) id() string { func (e Edge) id() string {
return fmt.Sprintf("%q-%q->%q", e.Tail, e.Val, e.Head) return fmt.Sprintf("%q->%q", e.Tail, e.Head)
} }
// an edgeIndex maps valueIDs to a set of edgeIDs. Graph keeps two edgeIndex's, // an edgeIndex maps valueIDs to a set of edgeIDs. Graph keeps two edgeIndex's,

View File

@ -44,21 +44,13 @@ func TestGraph(t *T) {
} }
} else if i == 1 { } else if i == 1 {
// delete edge which isn't there // delete edge which isn't there
p.del = Edge{Tail: strV("z"), Val: strV("z"), Head: strV("z")} p.del = Edge{Tail: strV("z"), Head: strV("z")}
} else if i <= 5 { } else if i <= 5 {
// add probably new edge // add probably new edge
p.add = Edge{ p.add = Edge{Tail: strV(mrand.Hex(1)), Head: strV(mrand.Hex(1))}
Tail: strV(mrand.Hex(1)),
Val: strV(mrand.Hex(1)),
Head: strV(mrand.Hex(1)),
}
} else { } else {
// probably del edge // probably del edge
p.del = Edge{ p.del = Edge{Tail: strV(mrand.Hex(1)), Head: strV(mrand.Hex(1))}
Tail: strV(mrand.Hex(1)),
Val: strV(mrand.Hex(1)),
Head: strV(mrand.Hex(1)),
}
} }
return mchk.Action{Params: p} return mchk.Action{Params: p}
}, },
@ -146,11 +138,7 @@ func TestSubGraphAndEqual(t *T) {
Next: func(ss mchk.State) mchk.Action { Next: func(ss mchk.State) mchk.Action {
i := mrand.Intn(10) i := mrand.Intn(10)
p := params{ p := params{
e: Edge{ e: Edge{Tail: strV(mrand.Hex(4)), Head: strV(mrand.Hex(4))},
Tail: strV(mrand.Hex(1)),
Val: strV(mrand.Hex(8)),
Head: strV(mrand.Hex(1)),
},
add1: i != 0, add1: i != 0,
add2: i != 1, add2: i != 1,
} }