Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // SocialGraphing.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <string>
- #include <fstream>
- #include <sstream>
- #include <iostream>
- #include <map>
- #include "Vertex.h"
- std::map<unsigned int, Vertex*> vertex_map;
- int _tmain(int argc, _TCHAR* argv[])
- {
- std::ifstream fin ("C:\\local\\sg\\Assignment3\\Teilaufgabe2\\symmetric_friends.txt");
- std::string myStr;
- while(getline(fin, myStr)) // Always put the read in the while condition.
- { // Then you only enter the loop if there is data to
- //use myStr data // processes. Otherwise you need to read and then
- std::istringstream iss(myStr);
- unsigned int id;
- iss >> id;
- Vertex* v = new Vertex(id);
- vertex_map[id] = v;
- }
- fin.close();
- fin.open("C:\\local\\sg\\Assignment3\\Teilaufgabe2\\symmetric_friends.txt");
- while(getline(fin, myStr)) // Always put the read in the while condition.
- { // Then you only enter the loop if there is data to
- //use myStr data // processes. Otherwise you need to read and then
- std::istringstream iss(myStr);
- unsigned int id;
- iss >> id;
- Vertex* v = vertex_map[id];
- while (iss >> id){
- v->addNeighbour(vertex_map[id]);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement