Example #1
0
	. "github.com/onsi/gomega"
)

var _ = Describe("Bread first search", func() {

	vertices := 10

	Context("Undirected graph", func() {

		var g graph.Graph
		var bfs BFS

		BeforeEach(func() {
			g = graph.New(vertices)
			for ind := 0; ind < vertices-1; ind++ {
				g.AddEdge(ind, ind+1)
			}
			bfs = Search(g, 0)
		})

		It("should perform bread first search", func() {

			Expect(bfs).NotTo(BeNil())
		})

		It("should verify that every node is connected", func() {

			for ind := 0; ind < vertices; ind++ {
				Expect(bfs.Marked(ind)).To(BeTrue())
			}
		})