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