src/work/marci/top_sort_test.cc
changeset 553 8e5102790d4d
parent 549 5531429143bc
child 557 9c0ce0a1f000
equal deleted inserted replaced
0:9fb2c88fbb6d 1:ea1b0130601a
     4 #include <list>
     4 #include <list>
     5 
     5 
     6 #include <hugo/dimacs.h>
     6 #include <hugo/dimacs.h>
     7 #include <bfs_dfs_misc.h>
     7 #include <bfs_dfs_misc.h>
     8 #include <list_graph.h>
     8 #include <list_graph.h>
       
     9 #include <graph_wrapper.h>
     9 
    10 
    10 using namespace hugo;
    11 using namespace hugo;
    11 
    12 
    12 int main() {
    13 int main() {
    13   typedef ListGraph Graph;
    14   typedef ListGraph Graph;
    14   Graph g;
    15   Graph g;
    15   readDimacs(std::cin, g);
    16   readDimacs(std::cin, g); 
    16   std::list<Graph::Node> l;
    17   {
    17   topSort(g, l);
    18     std::list<Graph::Node> l;
    18   std::cout << "Leaving order of dfs which is pretopological..." << std::endl;
    19     topSort(g, l);
    19   for(std::list<Graph::Node>::const_iterator i=l.begin(); i!=l.end(); ++i) {
    20     std::cout << "Leaving order of dfs which is pretopological..." << std::endl;
    20     std::cout << *i << " ";
    21     for(std::list<Graph::Node>::const_iterator i=l.begin(); i!=l.end(); ++i) {
       
    22       std::cout << *i << " ";
       
    23     }
       
    24     std::cout << std::endl;
    21   }
    25   }
    22   std::cout << std::endl;
    26   
       
    27   {
       
    28     typedef RevGraphWrapper<Graph> GW;
       
    29     GW gw(g);
       
    30     std::list<GW::Node> l;
       
    31     topSort(gw, l);
       
    32     std::cout << "Same in the revered oriented graph..." << std::endl;
       
    33     for(std::list<GW::Node>::const_iterator i=l.begin(); i!=l.end(); ++i) {
       
    34       std::cout << *i << " ";
       
    35     }
       
    36     std::cout << std::endl;
       
    37   }
    23 
    38 
    24   return 0;
    39   return 0;
    25 }
    40 }