Advances in UndirGraph.
* IterableExtender is complete
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();
51 typedef ResGraphWrapper<Graph1, int,
52 ConstMap<Graph1, int>, ConstMap<Graph1, int> > Graph4;
53 checkConcept<StaticGraph, MergeEdgeGraphWrapper<Graph1, Graph4> >();
54 MergeEdgeGraphWrapper<Graph1, Graph4>::printNode();
55 MergeEdgeGraphWrapper<Graph1, Graph4>::printEdge();
56 checkConcept<StaticGraph, MergeEdgeGraphWrapper<Graph4, Graph1> >();
57 MergeEdgeGraphWrapper<Graph4, Graph1>::printNode();
58 MergeEdgeGraphWrapper<Graph4, Graph1>::printEdge();
63 typedef MergeEdgeGraphWrapper<Graph1, Graph2> GW;
66 std::ifstream f1("graph1.dim");
67 std::ifstream f2("graph2.dim");
71 cout << "1st graph" << endl;
74 cout << "2nd graph" << endl;
77 cout << "merged graph" << endl;
84 cout << "SECOND TEST" << endl;
85 typedef SmartGraph Graph1;
87 checkConcept<StaticGraph, Graph1>();
93 ConstMap<FullGraph::Edge, bool> const_false_map(false);
94 typedef EdgeSubGraphWrapper<FullGraph, ConstMap<FullGraph::Edge, bool> >
97 checkConcept<StaticGraph, Graph2>();
100 Graph2 g2(pre_g2, const_false_map);
102 typedef MergeEdgeGraphWrapper<Graph1, Graph2> GW;
104 checkConcept<StaticGraph, GW>();
110 Graph2::NodeIt k(g2);
111 sw=GW::Node(INVALID, k, true);
113 tw=GW::Node(INVALID, k, true);
116 std::ifstream f1("graph2.dim");
119 cout << "1st graph" << endl;
122 cout << "2nd graph" << endl;
125 cout << "merged graph" << endl;
128 typedef ListGraph Graph3;
129 //typedef SmartGraph Graph3;
131 GW::NodeMap<Graph3::Node> gwn(gw);
132 Graph3::NodeMap<GW::Node> g3n(g3);
133 for (GW::NodeIt n(gw); n!=INVALID; ++n) {
134 Graph3::Node m=g3.addNode();
139 typedef NewEdgeSetGraphWrapper<GW, Graph3> GWW;
141 checkConcept<StaticGraph, GWW>();
144 GWW gww(gw, g3, gwn, g3n);
146 for (Graph1::NodeIt n(g1); n!=INVALID; ++n) {
147 g3.addEdge(gwn[sw], gwn[GW::Node(n,INVALID,false)]);
150 // for (Graph1::NodeIt n(g1); n!=INVALID; ++n) {
151 // gww.addEdge(sw, GW::Node(n,INVALID,false));
154 cout << "new edges" << endl;
157 cout << "new edges in the new graph" << endl;
160 typedef AugmentingGraphWrapper<GW, GWW> GWWW;
162 checkConcept<StaticGraph, GWWW>();
166 cout << "new edges merged into the original graph" << endl;