Esempio n. 1
0
        private static void TestBFS()
        {
            Graph  g  = new Graph();
            Vertex v1 = new Vertex();
            Vertex v2 = new Vertex();
            Vertex v3 = new Vertex();
            Vertex v4 = new Vertex();
            Vertex v5 = new Vertex();
            Vertex v6 = new Vertex();
            Vertex v7 = new Vertex();

            g.AddVertex(v1);
            g.AddVertex(v2);
            g.AddVertex(v3);
            g.AddVertex(v4);
            g.AddVertex(v5);
            g.AddVertex(v6);
            g.AddVertex(v7);

            g.AddEdge(new Edge(v1, v2));
            g.AddEdge(new Edge(v1, v3));
            g.AddEdge(new Edge(v2, v6));
            g.AddEdge(new Edge(v2, v4));
            g.AddEdge(new Edge(v6, v4));
            g.AddEdge(new Edge(v4, v5));

            List <Edge> path = GraphAlgorithms.BreadthFirstSearch(g, 0, 4);
        }