Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int vertex::count = 0;
- vertex::vertex(point coordinates)
- {
- id = vertex::count;
- vertex::count++;
- coords = coordinates;
- }
- vertex::vertex(string vertexname)
- {
- id = vertex::count;
- vertex::count++;
- name = vertexname;
- }
- void vertex::addNeighbour(vertex* neigh)
- {
- neighbours.push_back(neigh);
- }
- string vertex::toString()
- {
- string str=getName();
- cout << "Printing vertex: " << str << endl;
- str.append(" at (");
- str.append(doubleToString(coords.x()));
- str.append("|");
- str.append(doubleToString(coords.y()));
- str.append("), has ");
- stringstream tmp;
- tmp << neighbours.size();
- str.append(tmp.str());
- str.append(" neighbours: |");
- for (vector <vertex*>::iterator it = neighbours.begin(); it != neighbours.end(); ++it)
- {
- cout << "Found neighbour "<< (*it)->getName() << endl; //this segfaults
- str.append((*it)->getName());
- str.append("|");
- }
- return str;
- }
- string vertex::getName()
- {
- return name;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement