static void dfs(GraphVertex[] graph, int i, ref bool[] visited, ref ComponentIndex ci) { visited[i] = true; if (graph[i] == null) { graph[i] = new GraphVertex(); } graph[i].componentIndex = ci; graph[i].componentIndex.verts.Add(i); foreach (int j in graph[i].neighbours) { if (!visited[j]) { dfs(graph, j, ref visited, ref ci); } } }
static void ReadInput(out GraphVertex[] graph, out Edge[] edges, out int[] removeEdges) { TextReader stream; if (File.Exists(FILENAME)) { var fileStream = File.OpenRead(FILENAME); stream = new StreamReader(fileStream); } else { stream = Console.In; } var nc = stream.ReadLine().Split(' '); int n = int.Parse(nc[0]); int c = int.Parse(nc[1]); graph = new GraphVertex[n + 1]; edges = new Edge[c + 1]; for (int i = 1; i <= c; i++) { var edgeInput = stream.ReadLine().Split(' '); edges[i] = new Edge() { start = int.Parse(edgeInput[0]), end = int.Parse(edgeInput[1]) }; AddEdge(ref graph, edges[i]); } int m = int.Parse(stream.ReadLine()); var removeInput = stream.ReadLine().Split(' '); removeEdges = new int[m]; for (int i = 0; i < m; i++) { removeEdges[i] = int.Parse(removeInput[i]); RemoveEdge(ref graph, edges[removeEdges[i]]); } }