Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Graph graph;
- std::string line;
- std::stringstream iss;
- Graph::Position position;
- double x, y, z = -1;
- while(!std::cin.eof())
- {
- getline(std::cin, line);
- if(line.length() != 0)
- {
- iss << line;
- iss >> x;
- iss >> y;
- iss >> z;
- if(z<0)
- {
- position.x = x;
- position.y = y;
- graph.addVertex(position);
- }
- else
- {
- graph.addEdge(x, y, z);
- }
- }
- iss.clear();
- line = "";
- }
- //-------------------------------------------------------------------------
- /*
- //int a, b;
- //double c;
- getline(std::cin, line);
- unsigned number_of_spaces;
- number_of_spaces = std::count(line.begin(), line.end(), ' ');
- while (number_of_spaces == 1)
- {
- iss << line;
- iss >> x;
- iss >> y;
- position.x = x;
- position.y = y;
- graph.addVertex(position);
- getline(std::cin, line);
- number_of_spaces = std::count(line.begin(), line.end(), ' ');
- iss.clear();
- }
- while (std::cin)
- {
- iss << line;
- iss >> a;
- iss >> b;
- iss >> c;
- graph.addEdge(a, b, c);
- getline(std::cin, line);
- iss.clear();
- }
- */
- //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement