// -*- c++ -*- #include #include #include #include #include #include #include #include #include using namespace hugo; using std::cout; using std::endl; int main() { typedef SageGraph Graph; Graph g; readDimacs(std::cin, g); { std::list l; //NullMap pred; Graph::NodeMap pred(g, INVALID); topSort(g, l, pred); cout << "Leaving order of dfs which is pretopological..." << endl; for(std::list::const_iterator i=l.begin(); i!=l.end(); ++i) { cout << *i << " "; } cout << endl; FOR_EACH_LOC(Graph::NodeIt, n, g) { cout << "pred of node " << n << " is " << pred[n] << endl; } } { typedef RevGraphWrapper GW; GW gw(g); std::list l; //NullMap pred; GW::NodeMap pred(gw, INVALID); topSort(gw, l, pred); cout << "Same in the reversed oriented graph..." << endl; for(std::list::const_iterator i=l.begin(); i!=l.end(); ++i) { cout << *i << " "; } cout << endl; FOR_EACH_LOC(GW::NodeIt, n, gw) { cout << "pred of node " << n << " is " << pred[n] << endl; } } return 0; }