Exemplo n.º 1
0
func (s *CollectionFunctorsSuite) TestCollectEdges(c *C) {
	slice := CollectEdges(spec.GraphLiteralFixture(true))

	c.Assert(len(slice), Equals, 2)

	set1 := set.NewNonTS()
	for _, e := range slice {
		set1.Add(e)
	}

	c.Assert(set1.Has(NewEdge("foo", "bar")), Equals, true)
	c.Assert(set1.Has(NewEdge("bar", "baz")), Equals, true)

	slice2 := CollectEdges(spec.GraphFixtures["2e3v"])

	c.Assert(len(slice2), Equals, 2)

	set2 := set.NewNonTS()
	for _, e := range slice2 {
		set2.Add(NewEdge(e.Both()))
	}

	c.Assert(set2.Has(NewEdge("foo", "bar")), Equals, true)
	c.Assert(set2.Has(NewEdge("bar", "baz")), Equals, true)
}
Exemplo n.º 2
0
func (s *CollectionFunctorsSuite) TestCollectVertices(c *C) {
	slice := CollectVertices(spec.GraphLiteralFixture(true))

	c.Assert(len(slice), Equals, 4)

	set1 := set.NewNonTS()
	for _, v := range slice {
		set1.Add(v)
	}

	c.Assert(set1.Has("foo"), Equals, true)
	c.Assert(set1.Has("bar"), Equals, true)
	c.Assert(set1.Has("baz"), Equals, true)
	c.Assert(set1.Has("isolate"), Equals, true)

	slice2 := CollectVertices(spec.GraphFixtures["2e3v"])

	c.Assert(len(slice2), Equals, 3)

	set2 := set.NewNonTS()
	for _, v := range slice2 {
		set2.Add(v)
	}

	c.Assert(set2.Has("foo"), Equals, true)
	c.Assert(set2.Has("bar"), Equals, true)
	c.Assert(set2.Has("baz"), Equals, true)
}
Exemplo n.º 3
0
func (s *CountingFunctorsSuite) TestSize(c *C) {
	el := EdgeList{
		NewEdge("foo", "bar"),
		NewEdge("bar", "baz"),
		NewEdge("foo", "qux"),
		NewEdge("qux", "bar"),
	}
	c.Assert(Size(el), Equals, 4)
	c.Assert(Size(spec.GraphLiteralFixture(true)), Equals, 2)
}
Exemplo n.º 4
0
func (s *CollectionFunctorsSuite) TestCollectEdgesIncidentTo(c *C) {
	slice := CollectEdgesIncidentTo("foo", spec.GraphLiteralFixture(true))

	c.Assert(len(slice), Equals, 1)

	set := set.NewNonTS()
	for _, e := range slice {
		set.Add(e)
	}

	c.Assert(set.Has(NewEdge("foo", "bar")), Equals, true)
}
Exemplo n.º 5
0
func (s *CollectionFunctorsSuite) TestCollectAdjacentVertices(c *C) {
	slice := CollectVerticesAdjacentTo("bar", spec.GraphLiteralFixture(true))

	c.Assert(len(slice), Equals, 2)

	set := set.NewNonTS()
	for _, v := range slice {
		set.Add(v)
	}

	c.Assert(set.Has("foo"), Equals, true)
	c.Assert(set.Has("baz"), Equals, true)
}