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(); }
public BFS_EdgeTo(Graph graph) { this.graph = graph; }
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; }
public DFS_Stack(Graph graph) { this.graph = graph; }