src/work/jacint/bug.cc
author alpar
Fri, 25 Mar 2005 16:19:03 +0000
changeset 1263 a490938ad0aa
parent 1059 bd97feae7d90
permissions -rw-r--r--
- LpGlpk added to the makefile
- missing const_cast<>() added
- prop for two new functions (solve() and solution())
jacint@1058
     1
#include <iostream>
jacint@1058
     2
#include <queue>
jacint@1058
     3
#include <vector>
jacint@1058
     4
#include <math.h>
jacint@1058
     5
jacint@1058
     6
#include <lemon/invalid.h>
jacint@1058
     7
#include <lemon/list_graph.h>
klao@1060
     8
#include <lemon/smart_graph.h>
jacint@1058
     9
#include <matching.h>
jacint@1058
    10
jacint@1058
    11
using namespace lemon;
klao@1060
    12
using namespace std;
jacint@1058
    13
jacint@1058
    14
klao@1060
    15
int main() {
klao@1060
    16
klao@1060
    17
  typedef UndirSmartGraph Graph;
jacint@1058
    18
jacint@1058
    19
  typedef Graph::Edge Edge;
jacint@1058
    20
  typedef Graph::UndirEdgeIt UndirEdgeIt;
jacint@1058
    21
  typedef Graph::IncEdgeIt IncEdgeIt;
jacint@1058
    22
  typedef Graph::NodeIt NodeIt;
jacint@1058
    23
  typedef Graph::Node Node;
klao@1060
    24
klao@1060
    25
  typedef Graph::OutEdgeIt OutEdgeIt;
jacint@1058
    26
   
jacint@1058
    27
  Graph G;
jacint@1058
    28
klao@1060
    29
  // G.clear();
jacint@1058
    30
  std::vector<Graph::Node> nodes;
jacint@1058
    31
  for (int i=0; i<5; ++i)
jacint@1058
    32
      nodes.push_back(G.addNode());
jacint@1058
    33
  G.addEdge(nodes[0], nodes[0]);
jacint@1058
    34
  G.addEdge(nodes[0], nodes[1]);
jacint@1058
    35
  G.addEdge(nodes[0], nodes[2]);  
jacint@1058
    36
  G.addEdge(nodes[0], nodes[4]);
jacint@1058
    37
  G.addEdge(nodes[2], nodes[3]);
jacint@1058
    38
  G.addEdge(nodes[1], nodes[2]);
jacint@1058
    39
  G.addEdge(nodes[2], nodes[4]);
jacint@1058
    40
jacint@1058
    41
  for(UndirEdgeIt e(G); e!=INVALID; ++e) {
klao@1060
    42
    std::cout<<G.id(e)<<" : "<<G.id(G.source(e))
klao@1060
    43
	     <<" " <<G.id(G.target(e))<<std::endl;
jacint@1058
    44
  }
jacint@1058
    45
jacint@1058
    46
  std::cout <<"Nodes:"<<std::endl;
jacint@1058
    47
jacint@1058
    48
  for(NodeIt v(G); v!=INVALID; ++v) {
jacint@1058
    49
    std::cout<<G.id(v)<<std::endl;
jacint@1058
    50
  }
jacint@1058
    51
klao@1060
    52
  cout << "Dev Out edges from node " << G.id(nodes[1])<<std::endl;
klao@1060
    53
  Edge f;
klao@1060
    54
  for(G.firstOut(f, nodes[1]); f!=INVALID; G.nextOut(f)) {
klao@1060
    55
    cout<<"edge " << G.id(f) << " goes"
klao@1060
    56
	     <<" from "<< G.id(G.source(f)) 
klao@1060
    57
	     << " to " << G.id(G.target(f))<<std::endl;
klao@1060
    58
  }
klao@1060
    59
klao@1060
    60
  cout << "Out edges from node " << G.id(nodes[1])<<std::endl;
klao@1060
    61
  for( OutEdgeIt f(G,nodes[1]); f!=INVALID; ++f ) {
klao@1060
    62
    cout<<"edge " << G.id(f) << " goes"
klao@1060
    63
	     <<" from "<< G.id(G.source(f)) 
klao@1060
    64
	     << " to " << G.id(G.target(f))<<std::endl;
klao@1060
    65
  }
klao@1060
    66
jacint@1059
    67
  std::cout<<"Edges of node " << G.id(nodes[1])<<std::endl;
klao@1060
    68
  for( IncEdgeIt f(G,nodes[1]); f!=INVALID; ++f ) {
klao@1060
    69
    cout<<"edge " << G.id(f) << " goes"
klao@1060
    70
	     <<" from "<< G.id(G.source(f)) 
klao@1060
    71
	     << " to " << G.id(G.target(f))<<std::endl;
klao@1060
    72
  }
jacint@1059
    73
klao@1060
    74
  //return 0;
klao@1060
    75
klao@1060
    76
  //ez a ket for ciklus meg lefut - bar hibas eleken iteral -, de a
klao@1060
    77
  //matching.h-s mar segfaultol
jacint@1058
    78
jacint@1058
    79
  for( IncEdgeIt f(G,nodes[1]); f!=INVALID; ++f ) {
jacint@1059
    80
    std::cout<<"edge " << G.id(f)<< " goes to " << G.id(G.target(f))<<std::endl;
jacint@1058
    81
  }
jacint@1058
    82
jacint@1058
    83
  MaxMatching<Graph> max_matching(G);
jacint@1058
    84
  max_matching.runEdmonds(0);
jacint@1058
    85
  
jacint@1058
    86
  return 0;
jacint@1058
    87
}
jacint@1058
    88