src/work/marci/top_sort_test.cc
changeset 609 0566ac97809b
parent 577 e8703f0a6e2f
child 640 d426dca0aaf7
     1.1 --- a/src/work/marci/top_sort_test.cc	Tue May 11 15:44:58 2004 +0000
     1.2 +++ b/src/work/marci/top_sort_test.cc	Tue May 11 15:54:00 2004 +0000
     1.3 @@ -8,35 +8,50 @@
     1.4  #include <list_graph.h>
     1.5  #include <hugo/graph_wrapper.h>
     1.6  #include <hugo/maps.h>
     1.7 +#include <for_each_macros.h>
     1.8  
     1.9  using namespace hugo;
    1.10  
    1.11 +using std::cout;
    1.12 +using std::endl;
    1.13 +
    1.14  int main() {
    1.15    typedef ListGraph Graph;
    1.16    Graph g;
    1.17    readDimacs(std::cin, g); 
    1.18 + 
    1.19    {
    1.20      std::list<Graph::Node> l;
    1.21 -    NullMap<Graph::Node, Graph::Edge> pred;
    1.22 +    //NullMap<Graph::Node, Graph::Edge> pred;
    1.23 +    Graph::NodeMap<Graph::Edge> pred(g, INVALID);
    1.24      topSort(g, l, pred);
    1.25 -    std::cout << "Leaving order of dfs which is pretopological..." << std::endl;
    1.26 +    cout << "Leaving order of dfs which is pretopological..." << endl;
    1.27      for(std::list<Graph::Node>::const_iterator i=l.begin(); i!=l.end(); ++i) {
    1.28 -      std::cout << *i << " ";
    1.29 +      cout << *i << " ";
    1.30      }
    1.31 -    std::cout << std::endl;
    1.32 +    cout << endl;
    1.33 +    
    1.34 +    FOR_EACH_LOC(Graph::NodeIt, n, g) {
    1.35 +      cout << "pred of node " << n << " is " << pred[n] << endl;
    1.36 +    }
    1.37    }
    1.38    
    1.39    {
    1.40      typedef RevGraphWrapper<Graph> GW;
    1.41      GW gw(g);
    1.42      std::list<GW::Node> l;
    1.43 -    NullMap<GW::Node, GW::Edge> pred;
    1.44 +    //NullMap<GW::Node, GW::Edge> pred;
    1.45 +    GW::NodeMap<Graph::Edge> pred(gw, INVALID);
    1.46      topSort(gw, l, pred);
    1.47 -    std::cout << "Same in the revered oriented graph..." << std::endl;
    1.48 +    cout << "Same in the reversed oriented graph..." << endl;
    1.49      for(std::list<GW::Node>::const_iterator i=l.begin(); i!=l.end(); ++i) {
    1.50 -      std::cout << *i << " ";
    1.51 +      cout << *i << " ";
    1.52      }
    1.53 -    std::cout << std::endl;
    1.54 +    cout << endl;
    1.55 +
    1.56 +    FOR_EACH_LOC(GW::NodeIt, n, gw) {
    1.57 +      cout << "pred of node " << n << " is " << pred[n] << endl;
    1.58 +    }
    1.59    }
    1.60  
    1.61    return 0;