model_server/edge/src/sugitopsort.cxx
/*
 * TopSortBottom
 *	Topological sort starting from max level
 */
TopSortBottom
Topological sort starting from max level
TopSortBottom Topological sort starting from max level
void TopSortBottom(graph* g)
{
  node *n;
  for (n = g->getheadnode(); n; n = n->getnextnode())
    n->setlevel(-1);
  g->set_nodes_unreached();
  g->setmaxlevel(0);
  DepthSearchBottom(FindBottomNodes(g), 0);
  for (n = g->getheadnode(); n; n = n->getnextnode())
    n->setlevel(g->getmaxlevel() - n->getlevel());
}
void TopSortBottom ( graph * g ) { node * n ; for ( n = g -> getheadnode ( ) ; n ; n = n -> getnextnode ( ) ) n -> setlevel ( -1 ) ; g -> set_nodes_unreached ( ) ; g -> setmaxlevel ( 0 ) ; DepthSearchBottom ( FindBottomNodes ( g ) , 0 ) ; for ( n = g -> getheadnode ( ) ; n ; n = n -> getnextnode ( ) ) n -> setlevel ( g -> getmaxlevel ( ) - n -> getlevel ( ) ) ; }
TopSortBottom
      Topological sort starting from max level
TopSortBottom Topological sort starting from max level
// initially mark nodes as being unreached // invert positions;