model_server/dagraph/src/DAGraph.cxx
//
// returns: -1: error, >=0: the node, and the nodes with removed references are removed
//
-1: error, >=0: the node, and the nodes with removed references are removed
- 1 : error > = 0 : the node and the nodes with removed references are removed
int
DAGraph::remove(DGNode * node)
{
    int ret_val = -1;
    if (node) {
	pqueue to_be_deleted;
	(void) to_be_deleted.insert((void *)node);
	(void) disconnect(node);
	if (node->outflow() > 0) {
	    if (algreset(0) >= 0) {
		int      sval = 0;
		DGNode * iter = (DGNode *)0;
		sval++; BFSEdges(node,iter,sval) {
		    if (_bfs_other)
			(_bfs_other->alg_value)++;
		} BFSEdgesEnd(sval);
		sval++; BFSEdges(node,iter,sval) {
		    if (_bfs_other!=0 && (iter->in_flow-iter->alg_value)!=0)
			(_bfs_other->alg_value)--;
		} BFSEdgesEnd(sval);
		sval++; BFSEdges(node,iter,sval) {
		    if (iter != node) {
			if ((iter->in_flow-iter->alg_value) == 0)
			    (void) to_be_deleted.insert((void *)iter);
			node = iter;
		    }
		} BFSEdgesEnd(sval);
	    }
	}
	ret_val = deleteNode(&to_be_deleted);
    }
    return ret_val;
}
int DAGraph :: remove ( DGNode * node ) { int ret_val = -1 ; if ( node ) { pqueue to_be_deleted ; ( void ) to_be_deleted . insert ( ( void * ) node ) ; ( void ) disconnect ( node ) ; if ( node -> outflow ( ) > 0 ) { if ( algreset ( 0 ) >= 0 ) { int sval = 0 ; DGNode * iter = ( DGNode * ) 0 ; sval ++ ; BFSEdges ( node , iter , sval ) { if ( _bfs_other ) ( _bfs_other -> alg_value ) ++ ; } BFSEdgesEnd ( sval ) ; sval ++ ; BFSEdges ( node , iter , sval ) { if ( _bfs_other != 0 && ( iter -> in_flow - iter -> alg_value ) != 0 ) ( _bfs_other -> alg_value ) -- ; } BFSEdgesEnd ( sval ) ; sval ++ ; BFSEdges ( node , iter , sval ) { if ( iter != node ) { if ( ( iter -> in_flow - iter -> alg_value ) == 0 ) ( void ) to_be_deleted . insert ( ( void * ) iter ) ; node = iter ; } } BFSEdgesEnd ( sval ) ; } } ret_val = deleteNode ( & to_be_deleted ) ; } return ret_val ; }
returns: -1: error, >=0: the node, and the nodes with removed references are removed
returns : - 1 : error > = 0 : the node and the nodes with removed references are removed
// -- remove references // -- get dependent nodes that need to be deleted // -- stage 1: compute the flow // -- stage 2: rectify stage 1 // -- stage 3: collect nodes for deletion // -- delete the collected nodes