File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -199,7 +199,7 @@ class Graph {
199199 in_edges_[layNext->getID ()].push_back (layPrev->getID ());
200200 }
201201
202- void removeConnection (int idPrev, int idNext) {
202+ void removeConnection (int idPrev, int idNext) {
203203 if (idPrev >= V_ || idNext >= V_ || idPrev < 0 || idNext < 0 ) {
204204 throw std::out_of_range (" Layer ID out of range" );
205205 }
@@ -237,21 +237,26 @@ class Graph {
237237 }
238238 }
239239 }
240- in_edges_.erase (in_edges_.begin () + id);
241240 // remove outputs
242- arrayE_.erase (arrayE_.begin () + arrayV_[id],
243- arrayE_.begin () + arrayV_[id + 1 ]);
244241 int amount_connected = arrayV_[id + 1 ] - arrayV_[id];
242+ for (int i = 0 ; i < amount_connected; i++) {
243+ removeConnection (id, arrayE_[arrayV_[id] + i]);
244+ }
245245 // remove vertex
246+ in_edges_.erase (in_edges_.begin () + id);
246247 arrayV_.erase (arrayV_.begin () + id);
247- for (size_t i = id; i < arrayV_.size (); i++) {
248- arrayV_[i] -= amount_connected;
249- }
250248 for (int & i : arrayE_) {
251249 if (i > id) {
252250 i -= 1 ;
253251 }
254252 }
253+ for (std::vector<int >& i : in_edges_) {
254+ for (int & j : i) {
255+ if (j > id) {
256+ j--;
257+ }
258+ }
259+ }
255260 for (size_t i = id + 1 ; i < layers_.size (); i++) {
256261 layers_[i]->setID (layers_[i]->getID () - 1 );
257262 }
You can’t perform that action at this time.
0 commit comments