graph: don't give values to edges, that can be accomplished by a transformation layer later
This commit is contained in:
parent
c1bdb46623
commit
9534ff5c13
@ -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,
|
||||||
|
@ -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,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user