src/work/jacint/bug.cc
author jacint
Fri, 07 Jan 2005 08:50:38 +0000
changeset 1059 bd97feae7d90
parent 1058 dddb01f98796
child 1060 7a24bb2e7480
permissions -rw-r--r--
(none)
jacint@1058
     1
//lasd megjegyzes a 49-es sorban
jacint@1058
     2
#include <iostream>
jacint@1058
     3
#include <queue>
jacint@1058
     4
#include <vector>
jacint@1058
     5
#include <math.h>
jacint@1058
     6
jacint@1058
     7
#include <lemon/invalid.h>
jacint@1058
     8
#include <lemon/list_graph.h>
jacint@1058
     9
#include <matching.h>
jacint@1058
    10
jacint@1058
    11
using namespace lemon;
jacint@1058
    12
jacint@1058
    13
int main(int, char **) {
jacint@1058
    14
jacint@1058
    15
  typedef UndirListGraph Graph;
jacint@1058
    16
jacint@1058
    17
  typedef Graph::Edge Edge;
jacint@1058
    18
  typedef Graph::UndirEdgeIt UndirEdgeIt;
jacint@1058
    19
  typedef Graph::IncEdgeIt IncEdgeIt;
jacint@1058
    20
  typedef Graph::NodeIt NodeIt;
jacint@1058
    21
  typedef Graph::Node Node;
jacint@1058
    22
   
jacint@1058
    23
  Graph G;
jacint@1058
    24
jacint@1058
    25
  G.clear();
jacint@1058
    26
  std::vector<Graph::Node> nodes;
jacint@1058
    27
  for (int i=0; i<5; ++i)
jacint@1058
    28
      nodes.push_back(G.addNode());
jacint@1058
    29
  G.addEdge(nodes[0], nodes[0]);
jacint@1058
    30
  G.addEdge(nodes[0], nodes[1]);
jacint@1058
    31
  G.addEdge(nodes[0], nodes[2]);  
jacint@1058
    32
  G.addEdge(nodes[0], nodes[4]);
jacint@1058
    33
  G.addEdge(nodes[2], nodes[3]);
jacint@1058
    34
  G.addEdge(nodes[1], nodes[2]);
jacint@1058
    35
  G.addEdge(nodes[2], nodes[4]);
jacint@1058
    36
jacint@1058
    37
  for(UndirEdgeIt e(G); e!=INVALID; ++e) {
jacint@1058
    38
    std::cout<<G.id(e)<<" : "<<G.id(G.source(e))<<" " <<G.id(G.target(e))<<std::endl;
jacint@1058
    39
  }
jacint@1058
    40
jacint@1058
    41
  std::cout <<"Nodes:"<<std::endl;
jacint@1058
    42
jacint@1058
    43
  for(NodeIt v(G); v!=INVALID; ++v) {
jacint@1058
    44
    std::cout<<G.id(v)<<std::endl;
jacint@1058
    45
  }
jacint@1058
    46
jacint@1059
    47
  std::cout<<"Edges of node " << G.id(nodes[1])<<std::endl;
jacint@1059
    48
jacint@1058
    49
  for( IncEdgeIt f(G,nodes[1]); f!=INVALID; ++f ) {
jacint@1059
    50
    std::cout<<"edge " << G.id(f)<< " goes to " << G.id(G.target(f))<<std::endl;
jacint@1058
    51
  }//ez a ket for ciklus meg lefut - bar hibas eleken iteral -, de a matching.h-s mar segfaultol
jacint@1058
    52
jacint@1058
    53
  for( IncEdgeIt f(G,nodes[1]); f!=INVALID; ++f ) {
jacint@1059
    54
    std::cout<<"edge " << G.id(f)<< " goes to " << G.id(G.target(f))<<std::endl;
jacint@1058
    55
  }
jacint@1058
    56
jacint@1058
    57
  MaxMatching<Graph> max_matching(G);
jacint@1058
    58
  max_matching.runEdmonds(0);
jacint@1058
    59
  
jacint@1058
    60
  return 0;
jacint@1058
    61
}
jacint@1058
    62