Advertisement
Ascar

Untitled

Jun 20th, 2014
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. // SocialGraphing.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <string>
  6. #include <fstream>
  7. #include <sstream>
  8. #include <iostream>
  9. #include <map>
  10. #include "Vertex.h"
  11.  
  12. std::map<unsigned int, Vertex*> vertex_map;
  13.  
  14. int _tmain(int argc, _TCHAR* argv[])
  15. {
  16. std::ifstream fin ("C:\\local\\sg\\Assignment3\\Teilaufgabe2\\symmetric_friends.txt");
  17. std::string myStr;
  18.  
  19.  
  20. while(getline(fin, myStr)) // Always put the read in the while condition.
  21. { // Then you only enter the loop if there is data to
  22. //use myStr data // processes. Otherwise you need to read and then
  23. std::istringstream iss(myStr);
  24. unsigned int id;
  25. iss >> id;
  26. Vertex* v = new Vertex(id);
  27. vertex_map[id] = v;
  28. }
  29. fin.close();
  30. fin.open("C:\\local\\sg\\Assignment3\\Teilaufgabe2\\symmetric_friends.txt");
  31.  
  32. while(getline(fin, myStr)) // Always put the read in the while condition.
  33. { // Then you only enter the loop if there is data to
  34. //use myStr data // processes. Otherwise you need to read and then
  35. std::istringstream iss(myStr);
  36. unsigned int id;
  37. iss >> id;
  38. Vertex* v = vertex_map[id];
  39. while (iss >> id){
  40. v->addNeighbour(vertex_map[id]);
  41. }
  42. }
  43.  
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement