Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. public static Tuple<Graph, Graph> ReadCSV(string path)
  2. {
  3. int sizeOfGraphA;
  4. int sizeOfGraphB;
  5. Graph GraphA;
  6. Graph GraphB;
  7. using (var reader = new StreamReader(path))
  8. {
  9. var fileNameParameters = Path.GetFileName(path).Split('_');
  10. sizeOfGraphA = int.Parse(fileNameParameters[0]);
  11. sizeOfGraphB = int.Parse(fileNameParameters[1]);
  12.  
  13. GraphA = new Graph(sizeOfGraphA);
  14.  
  15. for (int i = 0; i < GraphA.VerticesCount; i++)
  16. {
  17. var values = reader.ReadLine().Split(',');
  18. for (int j = 0; j < GraphA.VerticesCount; j++)
  19. {
  20. if (values[j] == "1")
  21. GraphA.AddEdge(i, j);
  22. }
  23. }
  24. }
  25.  
  26. path.Replace("_A_", "_B_");
  27.  
  28. using (var reader = new StreamReader(path))
  29. {
  30. GraphB = new Graph(sizeOfGraphB);
  31. for (int i = 0; i < GraphB.VerticesCount; i++)
  32. {
  33. var values = reader.ReadLine().Split(',');
  34. for (int j = 0; j < GraphB.VerticesCount; j++)
  35. {
  36. if (values[j] == "1")
  37. GraphB.AddEdge(i, j);
  38. }
  39. }
  40. }
  41. return new Tuple<Graph, Graph>(GraphA, GraphB);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement