1.1 --- a/src/work/marci/merge_node_graph_wrapper_test.cc Thu Nov 18 22:31:21 2004 +0000
1.2 +++ b/src/work/marci/merge_node_graph_wrapper_test.cc Fri Nov 19 17:22:29 2004 +0000
1.3 @@ -1,7 +1,9 @@
1.4 #include <iostream>
1.5 +#include <fstream>
1.6
1.7 #include <lemon/list_graph.h>
1.8 #include <lemon/smart_graph.h>
1.9 +#include <lemon/dimacs.h>
1.10 #include <merge_node_graph_wrapper.h>
1.11
1.12 #include<lemon/concept_check.h>
1.13 @@ -23,22 +25,64 @@
1.14 typedef SmartGraph Graph1;
1.15 typedef ListGraph Graph2;
1.16
1.17 -// {
1.18 -// checkConcept<StaticGraph, NewEdgeSetGraphWrapper<Graph1, Graph2> >();
1.19 -// }
1.20 {
1.21 + checkConcept<StaticGraph, NewEdgeSetGraphWrapper<Graph1, Graph2> >();
1.22 + }
1.23 + {
1.24 + checkConcept<StaticGraph, MergeEdgeGraphWrapper<Graph1, Graph2> >();
1.25 + }
1.26 +
1.27 Graph1 g;
1.28 Graph2 h;
1.29 - typedef MergeNodeGraphWrapper<Graph1, Graph2> GW;
1.30 + typedef MergeEdgeGraphWrapper<Graph1, Graph2> GW;
1.31 GW gw(g, h);
1.32 - Graph1::Node n1=g.addNode();
1.33 - Graph1::Node n2=g.addNode();
1.34 - Graph1::Node n3=g.addNode();
1.35 - Graph2::Node n4=h.addNode();
1.36 - Graph2::Node n5=h.addNode();
1.37 +
1.38 + std::ifstream f1("graph1.dim");
1.39 + std::ifstream f2("graph2.dim");
1.40 + readDimacs(f1, g);
1.41 + readDimacs(f2, h);
1.42 + {
1.43 +
1.44 +// Graph1::Node n1=g.addNode();
1.45 +// Graph1::Node n2=g.addNode();
1.46 +// Graph1::Node n3=g.addNode();
1.47 +// Graph2::Node n4=h.addNode();
1.48 +// Graph2::Node n5=h.addNode();
1.49 +// Graph2::Node n6=h.addNode();
1.50 +// Graph1::Edge e1=g.addEdge(n1, n2);
1.51 +// Graph1::Edge e2=g.addEdge(n1, n3);
1.52 +// Graph2::Edge e3=h.addEdge(n4, n5);
1.53 +// Graph2::Edge e4=h.addEdge(n4, n5);
1.54 //GW::NodeIt n(gw)
1.55 + cout << "1st graph" << endl;
1.56 + cout << " nodes:" << endl;
1.57 + for (Graph1::NodeIt n(g); n!=INVALID; ++n) {
1.58 + cout << " " << g.id(n) << endl;
1.59 + }
1.60 + cout << " edges:" << endl;
1.61 + for (Graph1::EdgeIt n(g); n!=INVALID; ++n) {
1.62 + cout << " " << g.id(n) << ": "
1.63 + << g.id(g.source(n)) << "->" << g.id(g.target(n)) << endl;
1.64 + }
1.65 + cout << "2nd graph" << endl;
1.66 + cout << " nodes:" << endl;
1.67 + for (Graph2::NodeIt n(h); n!=INVALID; ++n) {
1.68 + cout << " " << h.id(n) << endl;
1.69 + }
1.70 + cout << " edges:" << endl;
1.71 + for (Graph2::EdgeIt n(h); n!=INVALID; ++n) {
1.72 + cout << " " << h.id(n) << ": "
1.73 + << h.id(h.source(n)) << "->" << h.id(h.target(n)) << endl;
1.74 + }
1.75 + cout << "merged graph" << endl;
1.76 + cout << " nodes:" << endl;
1.77 for (GW::NodeIt n(gw); n!=INVALID; ++n) {
1.78 - cout << gw.id(n) << endl;
1.79 + cout << " "<< gw.id(n) << endl;
1.80 + }
1.81 + cout << " edges:" << endl;
1.82 + for (GW::EdgeIt n(gw); n!=INVALID; ++n) {
1.83 + cout << " " << gw.id(n) << ": "
1.84 + << gw.id(gw.source(n)) << "->" << gw.id(gw.target(n)) << endl;
1.85 }
1.86
1.87 GW::NodeMap<int> nm(gw);
1.88 @@ -48,13 +92,13 @@
1.89 nm.set(n, i);
1.90 }
1.91 for (Graph1::NodeIt n(g); n!=INVALID; ++n) {
1.92 - cout << nm[n] << endl;
1.93 + cout << nm[GW::Node(n,INVALID,false)] << endl;
1.94 }
1.95 for (Graph2::NodeIt n(h); n!=INVALID; ++n) {
1.96 - cout << nm[n] << endl;
1.97 + cout << nm[GW::Node(INVALID,n,true)] << endl;
1.98 }
1.99
1.100 - gw.print();
1.101 + gw.printNode();
1.102
1.103 {
1.104 // typedef SmartGraph Graph1;
1.105 @@ -64,7 +108,7 @@
1.106 Graph2 h;
1.107 typedef MergeNodeGraphWrapper<Graph1, Graph2> GW;
1.108 GW gw(g, h);
1.109 - gw.print();
1.110 + gw.printNode();
1.111 }
1.112 {
1.113 // typedef SmartGraph Graph1;
1.114 @@ -74,7 +118,7 @@
1.115 Graph2 h;
1.116 typedef MergeNodeGraphWrapper<Graph1, Graph2> GW;
1.117 GW gw(g, h);
1.118 - gw.print();
1.119 + gw.printNode();
1.120 }
1.121 {
1.122 // typedef SmartGraph Graph1;
1.123 @@ -84,7 +128,7 @@
1.124 Graph2 h;
1.125 typedef MergeNodeGraphWrapper<Graph1, Graph2> GW;
1.126 GW gw(g, h);
1.127 - gw.print();
1.128 + gw.printNode();
1.129 }
1.130 }
1.131 {