UPD: I rewrote the code and don’t understand why it crashes to for(j = gr[i].list.begin(); j != gr[i].list.end(); ++j)
The code itself http://pastebin.com/aHsGD2GK
I declare structures
struct tlist { int inf; tlist *next; }; struct orgraph { int top; tlist *first; }; void insert(orgraph *gr, int x, int y) { tlist *cur = gr[x].first; tlist *pr = NULL; tlist* now = new tlist; now->inf = y; now->next = NULL; while(cur != NULL) { pr = cur; cur = cur->next; } if(pr == NULL) { gr[x].first = now; } else { pr->next = now; } }
And everything seems fine, but I need to remove the arc connecting the vertices a and b. And here I am in a stupor, what to do. Understand, what
void delete_xy(orgraph *gr, int x, int y) { tlist *tmp = gr[x].first; }
Well, how can I erase Y?