Avatar
omochimetaru 2/4/2020 9:22 AM
// For every j->target, j != source for(list<int>::iterator j = Graph[MM-1][target].in.begin(); j != Graph[MM-1][target].in.end(); j++) { if( !Graph[MM][*j].alive ) continue; // For every source->k for(list<int>::iterator k = Graph[MM][source].out.begin(); k != Graph[MM][source].out.end(); k++) { // Search for j->k. If found, remove it; if not, add it. list<int>::iterator search; for(search = Graph[MM][*j].out.begin(); search != Graph[MM][*j].out.end(); search++ ) if (*search == *k) { Graph[MM][*j].out.erase( search ); if( *k != target) Graph[MM-1][*k].in.remove(*j); break; } if (search == Graph[MM][*j].out.end()){ Graph[MM][*j].out.push_back(*k); Graph[MM-1][*k].in.push_back(*j); } } }