From 9534ff5c1366a0ec8e878cb4ab12f2cedd485851 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Sat, 18 Aug 2018 14:06:43 -0400 Subject: [PATCH] graph: don't give values to edges, that can be accomplished by a transformation layer later --- graph/graph.go | 6 +++--- graph/graph_test.go | 20 ++++---------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/graph/graph.go b/graph/graph.go index ec1ae4c..e218f98 100644 --- a/graph/graph.go +++ b/graph/graph.go @@ -34,13 +34,13 @@ func NewValue(V interface{}) Value { } // 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 { - Tail, Val, Head Value + Tail, Head Value } 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, diff --git a/graph/graph_test.go b/graph/graph_test.go index a9b0e0b..67168e2 100644 --- a/graph/graph_test.go +++ b/graph/graph_test.go @@ -44,21 +44,13 @@ func TestGraph(t *T) { } } else if i == 1 { // 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 { // add probably new edge - p.add = Edge{ - Tail: strV(mrand.Hex(1)), - Val: strV(mrand.Hex(1)), - Head: strV(mrand.Hex(1)), - } + p.add = Edge{Tail: strV(mrand.Hex(1)), Head: strV(mrand.Hex(1))} } else { // probably del edge - p.del = Edge{ - Tail: strV(mrand.Hex(1)), - Val: strV(mrand.Hex(1)), - Head: strV(mrand.Hex(1)), - } + p.del = Edge{Tail: strV(mrand.Hex(1)), Head: strV(mrand.Hex(1))} } return mchk.Action{Params: p} }, @@ -146,11 +138,7 @@ func TestSubGraphAndEqual(t *T) { Next: func(ss mchk.State) mchk.Action { i := mrand.Intn(10) p := params{ - e: Edge{ - Tail: strV(mrand.Hex(1)), - Val: strV(mrand.Hex(8)), - Head: strV(mrand.Hex(1)), - }, + e: Edge{Tail: strV(mrand.Hex(4)), Head: strV(mrand.Hex(4))}, add1: i != 0, add2: i != 1, }