src/work/marci/merge_node_graph_wrapper_test.cc
changeset 1008 3fef334f5f37
parent 1007 a7d5fe18d8f9
child 1009 8cb323dbae93
equal deleted inserted replaced
3:2421ac79bb6b 4:d5852f89a8c1
     2 
     2 
     3 #include <lemon/list_graph.h>
     3 #include <lemon/list_graph.h>
     4 #include <lemon/smart_graph.h>
     4 #include <lemon/smart_graph.h>
     5 #include <merge_node_graph_wrapper.h>
     5 #include <merge_node_graph_wrapper.h>
     6 
     6 
       
     7 #include<lemon/concept_check.h>
       
     8 #include<lemon/concept/graph.h>
       
     9 
     7 using std::cout;
    10 using std::cout;
     8 using std::endl;
    11 using std::endl;
     9 
    12 
    10 using namespace lemon;
    13 using namespace lemon;
       
    14 using namespace lemon::concept;
    11 
    15 
    12 class Graph3 : ListGraph {
    16 class Graph3 : ListGraph {
    13 public:
    17 public:
    14   class Node : public ListGraph::Node { };
    18   class Node : public ListGraph::Node { };
    15   class Edge { };
    19   class Edge { };
    16 };
    20 };
    17 
    21 
    18 int main() {
    22 int main() {
    19   typedef SmartGraph Graph1;
    23   typedef SmartGraph Graph1;
    20   typedef ListGraph Graph2;
    24   typedef ListGraph Graph2;
       
    25   
       
    26 //   {
       
    27 //     checkConcept<StaticGraph, NewEdgeSetGraphWrapper<Graph1, Graph2> >(); 
       
    28 //   }
       
    29   {
    21   Graph1 g;
    30   Graph1 g;
    22   Graph2 h;
    31   Graph2 h;
    23   typedef MergeNodeGraphWrapper<Graph1, Graph2> GW;
    32   typedef MergeNodeGraphWrapper<Graph1, Graph2> GW;
    24   GW gw(g, h);
    33   GW gw(g, h);
    25   Graph1::Node n1=g.addNode();
    34   Graph1::Node n1=g.addNode();
    75     Graph2 h;
    84     Graph2 h;
    76     typedef MergeNodeGraphWrapper<Graph1, Graph2> GW;
    85     typedef MergeNodeGraphWrapper<Graph1, Graph2> GW;
    77     GW gw(g, h);    
    86     GW gw(g, h);    
    78     gw.print();
    87     gw.print();
    79   }
    88   }
       
    89   }
       
    90   {
       
    91     Graph1 g;
       
    92     Graph2 h;
       
    93     typedef Graph1::Node Node1;
       
    94     typedef Graph2::Node Node2;
       
    95     typedef NewEdgeSetGraphWrapper<Graph1, Graph2> GW;
       
    96     Graph1::NodeMap<Graph2::Node> e_node(g);
       
    97     Graph2::NodeMap<Graph1::Node> n_node(h);
       
    98     GW gw(g, h, e_node, n_node);
       
    99     for (int i=0; i<4; ++i) { 
       
   100       Node1 n=g.addNode();
       
   101       e_node.set(n, INVALID);
       
   102     }
       
   103     for (int i=0; i<4; ++i) {
       
   104       Graph1::Node n1=g.addNode();
       
   105       Graph2::Node n2=h.addNode();
       
   106       e_node.set(n1, n2);
       
   107       n_node.set(n2, n1);
       
   108     }
       
   109     for (Graph2::NodeIt n(h); n!=INVALID; ++n)
       
   110       for (Graph2::NodeIt m(h); m!=INVALID; ++m)
       
   111 	if ((h.id(n)+h.id(m))%3==0) h.addEdge(n, m);
       
   112 //     Graph1::NodeIt n(g);
       
   113 //     Node1 n1=n;
       
   114 //     Node1 n2=++n;
       
   115 //     Node1 n3=++n;
       
   116 //     Node1 n4=n;
       
   117 //     gw.addEdge(n1, n2);
       
   118 //     gw.addEdge(n1, n2);
       
   119 //     for (EdgeIt(e))
       
   120 //   Graph1::Node n1=g.addNode();
       
   121 //   Graph1::Node n2=g.addNode();
       
   122 //   Graph1::Node n3=g.addNode();
       
   123 //   Graph2::Node n4=h.addNode();
       
   124 //   Graph2::Node n5=h.addNode();
       
   125     for (GW::EdgeIt e(gw); e!=INVALID; ++e) 
       
   126       cout << gw.id(e) << endl;
       
   127     for (GW::NodeIt n(gw); n!=INVALID; ++n) {
       
   128       if (e_node[n]==INVALID) {
       
   129  	cout<<gw.id(n)<<" INVALID"<<endl;
       
   130       } else {
       
   131 	cout <<gw.id(n)<<" "<<h.id(e_node[n])<<" out_edges: ";
       
   132 	//	cout << &e_node << endl;
       
   133 	//cout << &n_node << endl;
       
   134 	for (GW::OutEdgeIt e(gw, n); e!=INVALID; ++e) {
       
   135 	  cout<<gw.id(e)<<" ";
       
   136 	}
       
   137 	cout<< endl;
       
   138       }
       
   139     }
       
   140   }
    80 }
   141 }