model_server/edge/src/sugitopsort.cxx
/*
 *FindBottomNodes
 *	Retuns a list of the nodes which should be on max. level.
 *	This includes all nodes with 0 succcessors and those for whom the
 *	number of succ + # incoming reversed edges - # outgoing reversed edges
 *	is 0 (because these have 0 successors from earlier in the graph).
 */
FindBottomNodes
Retuns a list of the nodes which should be on max. level.
This includes all nodes with 0 succcessors and those for whom the
number of succ + # incoming reversed edges - # outgoing reversed edges
is 0 (because these have 0 successors from earlier in the graph).
FindBottomNodes Retuns a list of the nodes which should be on max . level . This includes all nodes with 0 succcessors and those for whom the number of succ + # incoming reversed edges - # outgoing reversed edges is 0 ( because these have 0 successors from earlier in the graph ) .
nlist* FindBottomNodes(graph* g)
{
  nlist* l = new nlist;
  for (node* n = g->getheadnode(); n; n = n->getnextnode())
      {
      int succ = n->countsucc();
      slist_iterator_forw iterp(*(slist*) n->getpredlist());
      node* p;
      while(p = (node*)iterp())
        if ((g->find_edge(p,n) != NULL) && (g->find_edge(p,n)->isreversed())) 
	    succ += 1;
      slist_iterator_forw iters(*(slist*) n->getsucclist());
      node* s;
       while(s = (node*)iters())
        if ((g->find_edge(n,s) != NULL) && (g->find_edge(n,s)->isreversed())) 
	    succ -= 1;
      if (succ == 0) 
	l->append(n);
    } 
  return l;
}
nlist * FindBottomNodes ( graph * g ) { nlist * l = new nlist ; for ( node * n = g -> getheadnode ( ) ; n ; n = n -> getnextnode ( ) ) { int succ = n -> countsucc ( ) ; slist_iterator_forw iterp ( * ( slist * ) n -> getpredlist ( ) ) ; node * p ; while ( p = ( node * ) iterp ( ) ) if ( ( g -> find_edge ( p , n ) != NULL ) && ( g -> find_edge ( p , n ) -> isreversed ( ) ) ) succ += 1 ; slist_iterator_forw iters ( * ( slist * ) n -> getsucclist ( ) ) ; node * s ; while ( s = ( node * ) iters ( ) ) if ( ( g -> find_edge ( n , s ) != NULL ) && ( g -> find_edge ( n , s ) -> isreversed ( ) ) ) succ -= 1 ; if ( succ == 0 ) l -> append ( n ) ; } return l ; }
FindBottomNodes
      Retuns a list of the nodes which should be on max.
FindBottomNodes Retuns a list of the nodes which should be on max .