model_server/edge/src/sugitopsort.cxx
/*
 * findparents
 *	returns a list of the parents of nodes in nodelist ll
 */
findparents
returns a list of the parents of nodes in nodelist ll
findparents returns a list of the parents of nodes in nodelist ll
nlist* findparents(nlist* ll)
{
  nlist* parentlist = new nlist;
  node* p;
  int flag = 0;
  slist_iterator_forw iter (*(slist*)ll);
  while (p=(node*)iter()) {
    if (!p->isreached()) {
      p->setreached(1);
      edge* e;
      if (p->countsucc() != 0) {
	slist_iterator_forw s_iter (*(slist*)p->find_edges_to_succs());
	while (e=(edge*)s_iter()) {
	  if (e->isreversed()) {
	    flag = 1;
	    parentlist->append(e->gettarget());
	  }
	}
      }
      if (p->countpred() != 0) {
	slist_iterator_forw p_iter (*(slist*)p->find_edges_from_preds());
	while (e=(edge*)p_iter()) {
	  if (!e->isreversed()) {
	    flag = 1;
	    parentlist->append(e->getsource());
	  }
	}
      }
    }
  }
  return parentlist;
}
nlist * findparents ( nlist * ll ) { nlist * parentlist = new nlist ; node * p ; int flag = 0 ; slist_iterator_forw iter ( * ( slist * ) ll ) ; while ( p = ( node * ) iter ( ) ) { if ( ! p -> isreached ( ) ) { p -> setreached ( 1 ) ; edge * e ; if ( p -> countsucc ( ) != 0 ) { slist_iterator_forw s_iter ( * ( slist * ) p -> find_edges_to_succs ( ) ) ; while ( e = ( edge * ) s_iter ( ) ) { if ( e -> isreversed ( ) ) { flag = 1 ; parentlist -> append ( e -> gettarget ( ) ) ; } } } if ( p -> countpred ( ) != 0 ) { slist_iterator_forw p_iter ( * ( slist * ) p -> find_edges_from_preds ( ) ) ; while ( e = ( edge * ) p_iter ( ) ) { if ( ! e -> isreversed ( ) ) { flag = 1 ; parentlist -> append ( e -> getsource ( ) ) ; } } } } } return parentlist ; }
findparents
      returns a list of the parents of nodes in nodelist ll
findparents returns a list of the parents of nodes in nodelist ll
// mark this node as reached