marci@549: // -*- c++ -*-
marci@549: #include <iostream>
marci@549: #include <fstream>
marci@549: #include <list>
marci@549: 
alpar@921: #include <lemon/dimacs.h>
marci@549: #include <bfs_dfs_misc.h>
marci@642: #include <sage_graph.h>
alpar@921: #include <lemon/graph_wrapper.h>
alpar@921: #include <lemon/maps.h>
marci@762: #include <for_each_macros.h>
marci@549: 
alpar@921: using namespace lemon;
marci@549: 
marci@609: using std::cout;
marci@609: using std::endl;
marci@609: 
marci@549: int main() {
marci@642:   typedef SageGraph Graph;
marci@549:   Graph g;
marci@552:   readDimacs(std::cin, g); 
marci@609:  
marci@552:   {
marci@552:     std::list<Graph::Node> l;
marci@609:     //NullMap<Graph::Node, Graph::Edge> pred;
marci@609:     Graph::NodeMap<Graph::Edge> pred(g, INVALID);
marci@577:     topSort(g, l, pred);
marci@609:     cout << "Leaving order of dfs which is pretopological..." << endl;
marci@552:     for(std::list<Graph::Node>::const_iterator i=l.begin(); i!=l.end(); ++i) {
marci@609:       cout << *i << " ";
marci@552:     }
marci@609:     cout << endl;
marci@609:     
marci@609:     FOR_EACH_LOC(Graph::NodeIt, n, g) {
marci@609:       cout << "pred of node " << n << " is " << pred[n] << endl;
marci@609:     }
marci@549:   }
marci@552:   
marci@552:   {
marci@552:     typedef RevGraphWrapper<Graph> GW;
marci@552:     GW gw(g);
marci@552:     std::list<GW::Node> l;
marci@609:     //NullMap<GW::Node, GW::Edge> pred;
marci@609:     GW::NodeMap<Graph::Edge> pred(gw, INVALID);
marci@577:     topSort(gw, l, pred);
marci@609:     cout << "Same in the reversed oriented graph..." << endl;
marci@552:     for(std::list<GW::Node>::const_iterator i=l.begin(); i!=l.end(); ++i) {
marci@609:       cout << *i << " ";
marci@552:     }
marci@609:     cout << endl;
marci@609: 
marci@609:     FOR_EACH_LOC(GW::NodeIt, n, gw) {
marci@609:       cout << "pred of node " << n << " is " << pred[n] << endl;
marci@609:     }
marci@552:   }
marci@549: 
marci@549:   return 0;
marci@549: }