4 #include <lemon/list_graph.h>
5 #include <lemon/smart_graph.h>
6 #include <lemon/dimacs.h>
7 #include <lemon/full_graph.h>
8 #include <merge_node_graph_wrapper.h>
10 #include<lemon/concept_check.h>
11 #include<lemon/concept/graph.h>
16 using namespace lemon;
17 using namespace lemon::concept;
19 class Graph3 : ListGraph {
21 class Node : public ListGraph::Node { };
25 template <typename Graph>
26 void printGraph(const Graph& g) {
27 cout << " nodes:" << endl;
28 for (typename Graph::NodeIt n(g); n!=INVALID; ++n) {
29 cout << " " << g.id(n) << endl;
31 cout << " edges:" << endl;
32 for (typename Graph::EdgeIt n(g); n!=INVALID; ++n) {
33 cout << " " << g.id(n) << ": "
34 << g.id(g.source(n)) << "->" << g.id(g.target(n)) << endl;
40 cout << "FIRST TEST" << endl;
41 typedef SmartGraph Graph1;
42 typedef ListGraph Graph2;
45 checkConcept<StaticGraph, MergeEdgeGraphWrapper<Graph1, Graph2> >();
46 MergeEdgeGraphWrapper<Graph1, Graph2>::printNode();
47 MergeEdgeGraphWrapper<Graph1, Graph2>::printEdge();
48 checkConcept<StaticGraph, MergeEdgeGraphWrapper<Graph1, Graph1> >();
49 MergeEdgeGraphWrapper<Graph1, Graph1>::printNode();
50 MergeEdgeGraphWrapper<Graph1, Graph1>::printEdge();
55 typedef MergeEdgeGraphWrapper<Graph1, Graph2> GW;
58 std::ifstream f1("graph1.dim");
59 std::ifstream f2("graph2.dim");
63 cout << "1st graph" << endl;
66 cout << "2nd graph" << endl;
69 cout << "merged graph" << endl;
76 cout << "SECOND TEST" << endl;
77 typedef SmartGraph Graph1;
79 checkConcept<StaticGraph, Graph1>();
85 ConstMap<FullGraph::Edge, bool> const_false_map(false);
86 typedef EdgeSubGraphWrapper<FullGraph, ConstMap<FullGraph::Edge, bool> >
89 checkConcept<StaticGraph, Graph2>();
92 Graph2 g2(pre_g2, const_false_map);
94 typedef MergeEdgeGraphWrapper<Graph1, Graph2> GW;
96 checkConcept<StaticGraph, GW>();
102 Graph2::NodeIt k(g2);
103 sw=GW::Node(INVALID, k, true);
105 tw=GW::Node(INVALID, k, true);
108 std::ifstream f1("graph2.dim");
111 cout << "1st graph" << endl;
114 cout << "2nd graph" << endl;
117 cout << "merged graph" << endl;
120 typedef ListGraph Graph3;
122 GW::NodeMap<Graph3::Node> gwn(gw);
123 Graph3::NodeMap<GW::Node> g3n(g3);
124 for (GW::NodeIt n(gw); n!=INVALID; ++n) {
125 Graph3::Node m=g3.addNode();
130 typedef NewEdgeSetGraphWrapper<GW, Graph3> GWW;
132 checkConcept<StaticGraph, GWW>();
135 GWW gww(gw, g3, gwn, g3n);
137 for (Graph1::NodeIt n(g1); n!=INVALID; ++n) {
138 g3.addEdge(gwn[sw], gwn[GW::Node(n,INVALID,false)]);
141 // for (Graph1::NodeIt n(g1); n!=INVALID; ++n) {
142 // gww.addEdge(sw, GW::Node(n,INVALID,false));
145 cout << "new edges" << endl;
148 cout << "new edges in the new graph" << endl;
151 typedef AugmentingGraphWrapper<GW, GWW> GWWW;
153 checkConcept<StaticGraph, GWWW>();
157 cout << "new edges merged into the original graph" << endl;