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