src/work/jacint/bug.cc
changeset 1327 ecc1cdea2ee7
parent 1059 bd97feae7d90
equal deleted inserted replaced
1:31e8f00727f7 2:087c46732458
     1 //lasd megjegyzes a 49-es sorban
       
     2 #include <iostream>
     1 #include <iostream>
     3 #include <queue>
     2 #include <queue>
     4 #include <vector>
     3 #include <vector>
     5 #include <math.h>
     4 #include <math.h>
     6 
     5 
     7 #include <lemon/invalid.h>
     6 #include <lemon/invalid.h>
     8 #include <lemon/list_graph.h>
     7 #include <lemon/list_graph.h>
       
     8 #include <lemon/smart_graph.h>
     9 #include <matching.h>
     9 #include <matching.h>
    10 
    10 
    11 using namespace lemon;
    11 using namespace lemon;
       
    12 using namespace std;
    12 
    13 
    13 int main(int, char **) {
       
    14 
    14 
    15   typedef UndirListGraph Graph;
    15 int main() {
       
    16 
       
    17   typedef UndirSmartGraph Graph;
    16 
    18 
    17   typedef Graph::Edge Edge;
    19   typedef Graph::Edge Edge;
    18   typedef Graph::UndirEdgeIt UndirEdgeIt;
    20   typedef Graph::UndirEdgeIt UndirEdgeIt;
    19   typedef Graph::IncEdgeIt IncEdgeIt;
    21   typedef Graph::IncEdgeIt IncEdgeIt;
    20   typedef Graph::NodeIt NodeIt;
    22   typedef Graph::NodeIt NodeIt;
    21   typedef Graph::Node Node;
    23   typedef Graph::Node Node;
       
    24 
       
    25   typedef Graph::OutEdgeIt OutEdgeIt;
    22    
    26    
    23   Graph G;
    27   Graph G;
    24 
    28 
    25   G.clear();
    29   // G.clear();
    26   std::vector<Graph::Node> nodes;
    30   std::vector<Graph::Node> nodes;
    27   for (int i=0; i<5; ++i)
    31   for (int i=0; i<5; ++i)
    28       nodes.push_back(G.addNode());
    32       nodes.push_back(G.addNode());
    29   G.addEdge(nodes[0], nodes[0]);
    33   G.addEdge(nodes[0], nodes[0]);
    30   G.addEdge(nodes[0], nodes[1]);
    34   G.addEdge(nodes[0], nodes[1]);
    33   G.addEdge(nodes[2], nodes[3]);
    37   G.addEdge(nodes[2], nodes[3]);
    34   G.addEdge(nodes[1], nodes[2]);
    38   G.addEdge(nodes[1], nodes[2]);
    35   G.addEdge(nodes[2], nodes[4]);
    39   G.addEdge(nodes[2], nodes[4]);
    36 
    40 
    37   for(UndirEdgeIt e(G); e!=INVALID; ++e) {
    41   for(UndirEdgeIt e(G); e!=INVALID; ++e) {
    38     std::cout<<G.id(e)<<" : "<<G.id(G.source(e))<<" " <<G.id(G.target(e))<<std::endl;
    42     std::cout<<G.id(e)<<" : "<<G.id(G.source(e))
       
    43 	     <<" " <<G.id(G.target(e))<<std::endl;
    39   }
    44   }
    40 
    45 
    41   std::cout <<"Nodes:"<<std::endl;
    46   std::cout <<"Nodes:"<<std::endl;
    42 
    47 
    43   for(NodeIt v(G); v!=INVALID; ++v) {
    48   for(NodeIt v(G); v!=INVALID; ++v) {
    44     std::cout<<G.id(v)<<std::endl;
    49     std::cout<<G.id(v)<<std::endl;
    45   }
    50   }
    46 
    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 
    47   std::cout<<"Edges of node " << G.id(nodes[1])<<std::endl;
    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   }
    48 
    73 
    49   for( IncEdgeIt f(G,nodes[1]); f!=INVALID; ++f ) {
    74   //return 0;
    50     std::cout<<"edge " << G.id(f)<< " goes to " << G.id(G.target(f))<<std::endl;
    75 
    51   }//ez a ket for ciklus meg lefut - bar hibas eleken iteral -, de a matching.h-s mar segfaultol
    76   //ez a ket for ciklus meg lefut - bar hibas eleken iteral -, de a
       
    77   //matching.h-s mar segfaultol
    52 
    78 
    53   for( IncEdgeIt f(G,nodes[1]); f!=INVALID; ++f ) {
    79   for( IncEdgeIt f(G,nodes[1]); f!=INVALID; ++f ) {
    54     std::cout<<"edge " << G.id(f)<< " goes to " << G.id(G.target(f))<<std::endl;
    80     std::cout<<"edge " << G.id(f)<< " goes to " << G.id(G.target(f))<<std::endl;
    55   }
    81   }
    56 
    82