示例#1
0
        public static void Test()
        {
            Graph graph = new Graph(10);

            graph.Connect(0, 2);
            graph.Connect(0, 1);
            graph.Connect(2, 4);
            graph.Connect(3, 4);
            graph.Connect(3, 5);
            graph.Connect(4, 5);
            graph.Connect(4, 6);
            graph.Connect(6, 8);

            GraphHandler handler = new BFS_EdgeTo(graph.Clone());

            handler.Path(0, 8).PrintToConsole();
        }
示例#2
0
 public BFS_EdgeTo(Graph graph)
 {
     this.graph = graph;
 }
示例#3
0
        public Graph Clone()
        {
            List<int>[] newEdges = new List<int>[vertices];

            for (int v = 0; v < vertices; v++)
            {
                //create list of edges for that vertice
                newEdges[v] = new List<int>();

                //add replicated edges
                foreach (int w in edges[v])
                {
                    newEdges[v].Add(w);
                }
            }

            Graph clone = new Graph(vertices);
            clone.edges = newEdges;
            return clone;
        }
示例#4
0
 public DFS_Stack(Graph graph)
 {
     this.graph = graph;
 }