Beispiel #1
0
        private bool Test_Path(int src, int dest, List <int> pathBack)
        {
            Console.WriteLine("Path from " + src + "to " + dest + "------------------");

            NodeGraphUndirected.BFS bfs = new NodeGraphUndirected.BFS(src, graph);

            var path = bfs.FindPath(dest);

            if (path.Count != pathBack.Count)
            {
                Console.WriteLine("Path back failed ---------------\n\n\n\n");
                return(false);
            }

            for (int i = 0; i < path.Count; ++i)
            {
                if (path[i].Id != pathBack[i])
                {
                    Console.WriteLine("Path back failed ---------------\n\n\n\n");
                    return(false);
                }
            }

            Console.WriteLine("Path back success ---------------\n\n\n\n");
            return(true);
        }
Beispiel #2
0
        private bool Test_BFS(int v)
        {
            Console.WriteLine("BFS on " + v + "------------------");

            Action <Vertex> early = vert => { Console.WriteLine("Early Processing Vertex " + vert.Id); };

            Action <Vertex, Vertex> process = (v1, v2) => { Console.WriteLine("Processing Edge " + v1.Id + " " + v2.Id); };

            Action <Vertex> late = vert => { Console.WriteLine("Late Processing Vertex " + vert.Id); };

            NodeGraphUndirected.BFS bfs = new NodeGraphUndirected.BFS(v, graph, early, process, late);

            Console.WriteLine("END BFS------------------\n\n\n\n");

            return(true);
        }