marci@915: #include marci@1009: #include marci@915: alpar@921: #include alpar@921: #include marci@1009: #include marci@1013: #include marci@915: #include marci@915: marci@1008: #include marci@1008: #include marci@1008: marci@915: using std::cout; marci@915: using std::endl; marci@915: alpar@921: using namespace lemon; marci@1008: using namespace lemon::concept; marci@915: marci@1007: class Graph3 : ListGraph { marci@1007: public: marci@1007: class Node : public ListGraph::Node { }; marci@1007: class Edge { }; marci@1007: }; marci@1007: marci@1013: template marci@1013: void printGraph(const Graph& g) { marci@1009: cout << " nodes:" << endl; marci@1013: for (typename Graph::NodeIt n(g); n!=INVALID; ++n) { marci@1009: cout << " " << g.id(n) << endl; marci@1009: } marci@1009: cout << " edges:" << endl; marci@1013: for (typename Graph::EdgeIt n(g); n!=INVALID; ++n) { marci@1009: cout << " " << g.id(n) << ": " marci@1009: << g.id(g.source(n)) << "->" << g.id(g.target(n)) << endl; marci@1013: } marci@1013: } marci@1013: marci@1013: int main() { marci@1013: { marci@1013: cout << "FIRST TEST" << endl; marci@1013: typedef SmartGraph Graph1; marci@1013: typedef ListGraph Graph2; marci@1013: marci@1013: { marci@1013: checkConcept >(); marci@1013: MergeEdgeGraphWrapper::printNode(); marci@1013: MergeEdgeGraphWrapper::printEdge(); marci@1013: checkConcept >(); marci@1013: MergeEdgeGraphWrapper::printNode(); marci@1013: MergeEdgeGraphWrapper::printEdge(); marci@1013: } marci@1013: marci@1013: Graph1 g1; marci@1013: Graph2 g2; marci@1013: typedef MergeEdgeGraphWrapper GW; marci@1013: GW gw(g1, g2); marci@1013: marci@1013: std::ifstream f1("graph1.dim"); marci@1013: std::ifstream f2("graph2.dim"); marci@1013: readDimacs(f1, g1); marci@1013: readDimacs(f2, g2); marci@1013: marci@1013: cout << "1st graph" << endl; marci@1013: printGraph(g1); marci@1013: marci@1013: cout << "2nd graph" << endl; marci@1013: printGraph(g2); marci@1013: marci@1013: cout << "merged graph" << endl; marci@1013: printGraph(gw); marci@1013: marci@915: } marci@917: marci@1013: marci@1013: { marci@1013: cout << "SECOND TEST" << endl; marci@1013: typedef SmartGraph Graph1; marci@1013: { marci@1013: checkConcept(); marci@1013: } marci@1013: marci@1013: Graph1 g1; marci@1013: marci@1013: FullGraph pre_g2(2); marci@1013: ConstMap const_false_map(false); marci@1013: typedef EdgeSubGraphWrapper > marci@1013: Graph2; marci@1013: { marci@1013: checkConcept(); marci@1013: } marci@1013: marci@1013: Graph2 g2(pre_g2, const_false_map); marci@1013: marci@1013: typedef MergeEdgeGraphWrapper GW; marci@1013: { marci@1013: checkConcept(); marci@1013: } marci@1013: GW gw(g1, g2); marci@1013: GW::Node sw; marci@1013: GW::Node tw; marci@1013: { marci@1013: Graph2::NodeIt k(g2); marci@1013: sw=GW::Node(INVALID, k, true); marci@1013: ++k; marci@1013: tw=GW::Node(INVALID, k, true); marci@1013: } marci@1013: marci@1013: std::ifstream f1("graph2.dim"); marci@1013: readDimacs(f1, g1); marci@1013: marci@1013: cout << "1st graph" << endl; marci@1013: printGraph(g1); marci@1013: marci@1013: cout << "2nd graph" << endl; marci@1013: printGraph(g2); marci@1013: marci@1013: cout << "merged graph" << endl; marci@1013: printGraph(gw); marci@1013: marci@1013: typedef ListGraph Graph3; marci@1013: Graph3 g3; marci@1013: GW::NodeMap gwn(gw); marci@1013: Graph3::NodeMap g3n(g3); marci@1013: for (GW::NodeIt n(gw); n!=INVALID; ++n) { marci@1013: Graph3::Node m=g3.addNode(); marci@1013: gwn.set(n, m); marci@1013: g3n.set(m, n); marci@1013: } marci@1013: marci@1013: typedef NewEdgeSetGraphWrapper GWW; marci@1013: { marci@1013: checkConcept(); marci@1013: } marci@1013: marci@1013: GWW gww(gw, g3, gwn, g3n); marci@1013: marci@1013: for (Graph1::NodeIt n(g1); n!=INVALID; ++n) { marci@1013: g3.addEdge(gwn[sw], gwn[GW::Node(n,INVALID,false)]); marci@1013: } marci@1013: marci@1013: // for (Graph1::NodeIt n(g1); n!=INVALID; ++n) { marci@1013: // gww.addEdge(sw, GW::Node(n,INVALID,false)); marci@1013: // } marci@1013: marci@1013: cout << "new edges" << endl; marci@1013: printGraph(g3); marci@1013: marci@1013: cout << "new edges in the new graph" << endl; marci@1013: printGraph(gww); marci@1013: marci@1013: typedef AugmentingGraphWrapper GWWW; marci@1013: { marci@1013: checkConcept(); marci@1013: } marci@1013: GWWW gwww(gw, gww); marci@1013: marci@1013: cout << "new edges merged into the original graph" << endl; marci@1013: printGraph(gwww); marci@1013: marci@917: } marci@1007: marci@915: }