src/work/marci/top_sort_test.cc
author marci
Mon, 10 May 2004 16:31:48 +0000
changeset 597 a6e2b02f496a
parent 557 9c0ce0a1f000
child 609 0566ac97809b
permissions -rw-r--r--
bfs, dfs docs
     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 }