COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/work/marci/top_sort_test.cc @ 609:0566ac97809b

Last change on this file since 609:0566ac97809b was 609:0566ac97809b, checked in by marci, 20 years ago

misc

File size: 1.3 KB
RevLine 
[549]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>
[557]9#include <hugo/graph_wrapper.h>
[577]10#include <hugo/maps.h>
[609]11#include <for_each_macros.h>
[549]12
13using namespace hugo;
14
[609]15using std::cout;
16using std::endl;
17
[549]18int main() {
19  typedef ListGraph Graph;
20  Graph g;
[552]21  readDimacs(std::cin, g);
[609]22 
[552]23  {
24    std::list<Graph::Node> l;
[609]25    //NullMap<Graph::Node, Graph::Edge> pred;
26    Graph::NodeMap<Graph::Edge> pred(g, INVALID);
[577]27    topSort(g, l, pred);
[609]28    cout << "Leaving order of dfs which is pretopological..." << endl;
[552]29    for(std::list<Graph::Node>::const_iterator i=l.begin(); i!=l.end(); ++i) {
[609]30      cout << *i << " ";
[552]31    }
[609]32    cout << endl;
33   
34    FOR_EACH_LOC(Graph::NodeIt, n, g) {
35      cout << "pred of node " << n << " is " << pred[n] << endl;
36    }
[549]37  }
[552]38 
39  {
40    typedef RevGraphWrapper<Graph> GW;
41    GW gw(g);
42    std::list<GW::Node> l;
[609]43    //NullMap<GW::Node, GW::Edge> pred;
44    GW::NodeMap<Graph::Edge> pred(gw, INVALID);
[577]45    topSort(gw, l, pred);
[609]46    cout << "Same in the reversed oriented graph..." << endl;
[552]47    for(std::list<GW::Node>::const_iterator i=l.begin(); i!=l.end(); ++i) {
[609]48      cout << *i << " ";
[552]49    }
[609]50    cout << endl;
51
52    FOR_EACH_LOC(GW::NodeIt, n, gw) {
53      cout << "pred of node " << n << " is " << pred[n] << endl;
54    }
[552]55  }
[549]56
57  return 0;
58}
Note: See TracBrowser for help on using the repository browser.