Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Tuple<Graph, Graph> ReadCSV(string path)
- {
- int sizeOfGraphA;
- int sizeOfGraphB;
- Graph GraphA;
- Graph GraphB;
- using (var reader = new StreamReader(path))
- {
- var fileNameParameters = Path.GetFileName(path).Split('_');
- sizeOfGraphA = int.Parse(fileNameParameters[0]);
- sizeOfGraphB = int.Parse(fileNameParameters[1]);
- GraphA = new Graph(sizeOfGraphA);
- for (int i = 0; i < GraphA.VerticesCount; i++)
- {
- var values = reader.ReadLine().Split(',');
- for (int j = 0; j < GraphA.VerticesCount; j++)
- {
- if (values[j] == "1")
- GraphA.AddEdge(i, j);
- }
- }
- }
- path.Replace("_A_", "_B_");
- using (var reader = new StreamReader(path))
- {
- GraphB = new Graph(sizeOfGraphB);
- for (int i = 0; i < GraphB.VerticesCount; i++)
- {
- var values = reader.ReadLine().Split(',');
- for (int j = 0; j < GraphB.VerticesCount; j++)
- {
- if (values[j] == "1")
- GraphB.AddEdge(i, j);
- }
- }
- }
- return new Tuple<Graph, Graph>(GraphA, GraphB);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement