From a40773d8b02c88cee8758cd1699f12bb7374e34a Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Mon, 27 Jun 2011 23:05:14 -0400 Subject: [PATCH] Fixed crash when removing vertex --- graph.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/graph.cpp b/graph.cpp index 793373d..fb20e68 100644 --- a/graph.cpp +++ b/graph.cpp @@ -114,7 +114,7 @@ bool Graph::add_vertex(int x, int y, int r, int colour, int score, Vertex* src) vertices.push_back(v); #ifdef DEBUG - fprintf(stderr, "debug: Graph::add_vertex(): added: x=%d, y=%d, r=%d, score=%d\n", v->x, v->y, v->r, v->score); + fprintf(stderr, "debug: Graph::add_vertex(): added: x=%d, y=%d, r=%d, score=%d, colour=%x\n", v->x, v->y, v->r, v->score, v->colour); #endif return true; @@ -143,11 +143,11 @@ void Graph::remove_vertex(Vertex* target) for (cursor = target->neighbors.begin(); cursor != target->neighbors.end(); cursor++) { - list::iterator subcursor = find(target->neighbors.begin(), - target->neighbors.end(), - *cursor); - assert(subcursor != target->neighbors.end()); - target->neighbors.erase(subcursor); + list::iterator subcursor = find((*cursor)->neighbors.begin(), + (*cursor)->neighbors.end(), + target); + assert(subcursor != (*cursor)->neighbors.end()); + (*cursor)->neighbors.erase(subcursor); } cursor = find(vertices.begin(), vertices.end(), target);