MCPcopy Create free account
hub / github.com/davisking/dlib / remove_node

Method remove_node

dlib/graph/graph_kernel_1.h:595–622  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

593 bool is_checked
594 >
595 void graph_kernel_1<T,E,mem_manager,is_checked>::
596 remove_node (
597 unsigned long index
598 )
599 {
600 checker::check_remove_node(index,*this);
601
602 node_type& n = *nodes[index];
603
604 // remove all edges pointing to this node from its neighbors
605 for (unsigned long i = 0; i < n.neighbors.size(); ++i)
606 {
607 // remove the edge from this specific parent
608 unsigned long pos = static_cast<unsigned long>(find(n.neighbors[i]->neighbors.begin(), n.neighbors[i]->neighbors.end(), &n) -
609 n.neighbors[i]->neighbors.begin());
610 n.neighbors[i]->neighbors.erase(n.neighbors[i]->neighbors.begin() + pos);
611 n.neighbors[i]->edges.erase(n.neighbors[i]->edges.begin() + pos);
612 }
613
614 // now remove this node by replacing it with the last node in the nodes vector
615 nodes[index] = nodes[nodes.size()-1];
616
617 // update the index for the node we just moved
618 nodes[index]->idx = index;
619
620 // now remove the duplicated node at the end of the vector
621 nodes.pop_back();
622 }
623
624// ----------------------------------------------------------------------------------------
625

Callers

nothing calls this directly

Calls 5

eraseMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
pop_backMethod · 0.45

Tested by

no test coverage detected