Beispiel #1
0
// TODO it would be better to not have to have this here, at all.
func emptyVT(v system.ProtoVertex) system.VertexTuple {
	var props []system.PropPair
	for k, v := range v.Properties() {
		props = append(props, pp(k, v))
	}

	return system.VertexTuple{
		Vertex:   system.NewVertex(v.Type(), 0, props...),
		InEdges:  ps.NewMap(),
		OutEdges: ps.NewMap(),
	}
}
Beispiel #2
0
func getGraphFixture() *coreGraph {
	g := &coreGraph{vtuples: ps.NewMap(), vserial: 0}

	// Manually populate the graph with some dummy vertices and edges.
	// These don't necessarily line up with any real schemas, on purpose.

	// edge, id 10, connects vid 1 to vid 2. msgid 2. type "dummy-edge-type1". one prop - "eprop1": "foo".
	edge10 := mkEdge(10, 1, 2, 2, "dummy-edge-type1", "eprop1", "foo")
	// edge, id 11, connects vid 3 to vid 1. msgid 3. type "dummy-edge-type2". one prop - "eprop2": "bar".
	edge11 := mkEdge(11, 3, 1, 3, "dummy-edge-type2", "eprop2", "bar")
	// edge, id 12, connects vid 3 to vid 4. msgid 4. type "dummy-edge-type2". one prop - "eprop2": "baz".
	edge12 := mkEdge(12, 3, 4, 3, "dummy-edge-type2", "eprop2", "baz")
	// edge, id 13, connects vid 3 to vid 4. msgid 4. type "dummy-edge-type3". two props - "eprop2": "qux", "eprop3": 42.
	edge13 := mkEdge(13, 3, 4, 4, "dummy-edge-type3", "eprop2", "bar", "eprop3", 42)

	// vid 1, type "env". two props - "prop1": "bar", "prop2": 42. msgid 1
	vt1 := mkTuple(1, system.NewVertex("env", 1, tprops("prop1", "foo", "prop2", 42)...), edge10, edge11) // one in, one out
	g.vtuples = g.vtuples.Set(strconv.Itoa(1), vt1)

	// vid 2, type "env". , "one prop - "prop1", "foo". msgid 2
	vt2 := mkTuple(2, system.NewVertex("env", 2, tprops("prop1", "bar")...), edge10) // one in
	g.vtuples = g.vtuples.Set(strconv.Itoa(2), vt2)

	// vid 3, type "vt2". two props - "prop1", "bar", "bowser", "moo". msgid 3
	vt3 := mkTuple(3, system.NewVertex("vt2", 3, tprops("prop1", "bar", "bowser", "moo")...), edge11, edge12, edge13) // three out
	g.vtuples = g.vtuples.Set(strconv.Itoa(3), vt3)

	// vid 4, type "vt3". three props - "prop1", "baz", "prop2", 42, "prop3", "qux". msgid 4
	vt4 := mkTuple(4, system.NewVertex("vt3", 4, tprops("prop1", "baz", "prop2", 42, "prop3", "qux")...), edge12, edge13) // two in, same origin
	g.vtuples = g.vtuples.Set(strconv.Itoa(4), vt4)

	// vid 5, type "vt3". no props, no edges. msgid 5
	vt5 := mkTuple(5, system.NewVertex("vt3", 5)) // none in or out
	g.vtuples = g.vtuples.Set(strconv.Itoa(5), vt5)
	g.vserial = 13

	return g
}