void Graph::removeNode(Gnode *node)
{
GnodePtrBagManip nodeMan(&d_nodes);
while(nodeMan){
if(nodeMan()==node){
for(GedgePtrBagIter it(nodeMan()->edges());it;++it){
d_edges.removeAll(it());
}
nodeMan.remove();
}
else{
nodeMan.advance();
}
}
}
Hence, in outline, the remove node process is thus:
void Graph::removeNode(Gnode *node)
{
GnodePtrBagManip nodeMan(&d_nodes); //construct the node bag manipulator
while(nodeMan){ //manually step through the nodes in the bag
if(nodeMan()==node){ //if we match the desired node
//remove all edges associated with this node
}
nodeMan.remove(); //the edges are gone, so remove node
//the remove method also moves to the next node
//in the bag
}
else{ //this is not the desired node so just advance
nodeMan.advance();
}
}
}
We need to discuss these methods in detail. The manipulator constructor is called to construct the nodeMan manipulator.