src/work/marci/top_sort_test.cc
author marci
Mon, 10 May 2004 08:25:10 +0000
changeset 593 b83b36ee7f10
parent 557 9c0ce0a1f000
child 609 0566ac97809b
permissions -rw-r--r--
comleteGraph
     1 // -*- c++ -*-
     2 #include <iostream>
     3 #include <fstream>
     4 #include <list>
     5 
     6 #include <hugo/dimacs.h>
     7 #include <bfs_dfs_misc.h>
     8 #include <list_graph.h>
     9 #include <hugo/graph_wrapper.h>
    10 #include <hugo/maps.h>
    11 
    12 using namespace hugo;
    13 
    14 int main() {
    15   typedef ListGraph Graph;
    16   Graph g;
    17   readDimacs(std::cin, g); 
    18   {
    19     std::list<Graph::Node> l;
    20     NullMap<Graph::Node, Graph::Edge> pred;
    21     topSort(g, l, pred);
    22     std::cout << "Leaving order of dfs which is pretopological..." << std::endl;
    23     for(std::list<Graph::Node>::const_iterator i=l.begin(); i!=l.end(); ++i) {
    24       std::cout << *i << " ";
    25     }
    26     std::cout << std::endl;
    27   }
    28   
    29   {
    30     typedef RevGraphWrapper<Graph> GW;
    31     GW gw(g);
    32     std::list<GW::Node> l;
    33     NullMap<GW::Node, GW::Edge> pred;
    34     topSort(gw, l, pred);
    35     std::cout << "Same in the revered oriented graph..." << std::endl;
    36     for(std::list<GW::Node>::const_iterator i=l.begin(); i!=l.end(); ++i) {
    37       std::cout << *i << " ";
    38     }
    39     std::cout << std::endl;
    40   }
    41 
    42   return 0;
    43 }