COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/work/marci/top_sort_test.cc @ 577:e8703f0a6e2f

Last change on this file since 577:e8703f0a6e2f was 577:e8703f0a6e2f, checked in by marci, 20 years ago

top-sort, dimacs mods.

File size: 1016 bytes
Line 
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
12using namespace hugo;
13
14int 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}
Note: See TracBrowser for help on using the repository browser.