hegyi@677: #include <string>
hegyi@677: #include <iostream>
hegyi@677: #include <stdio.h>
hegyi@677: 
hegyi@677: #include "edgepathgraph.h"
hegyi@677: #include <hugo/list_graph.h>
hegyi@677: #include <hugo/smart_graph.h>
hegyi@677: #include <path.h>
hegyi@677: 
hegyi@677: using namespace hugo;
hegyi@677: using namespace std;
hegyi@677: 
hegyi@677: bool passed = true;
hegyi@677: 
hegyi@677: void check(bool rc) {
hegyi@677:   passed = passed && rc;
hegyi@677:   if(!rc) {
hegyi@677:     cout << "Test failed!" << endl;
hegyi@677:   }
hegyi@677: }
hegyi@677: 
hegyi@677: int main()
hegyi@677: {
hegyi@677:   {
hegyi@677:       EdgePathGraph<DirPath<ListGraph>, SmartGraph, ListGraph> EPGr;
hegyi@677:       EPGr.addNode();
hegyi@677:       EPGr.addNode();
hegyi@677:       EPGr.addNode();
hegyi@677:       EPGr.addNode();
hegyi@677:       printf("%d node is in EPGr, after addition of 4 nodes.\n", EPGr.nodeNum());
hegyi@677: 
hegyi@677:       EdgePathGraph<DirPath<ListGraph>, SmartGraph, ListGraph> EPGr2(EPGr);
hegyi@677:       printf("%d node is in EPGr2 created by copy constructor from EPGr.\n", EPGr2.nodeNum());
hegyi@677: 
hegyi@677:       EPGr2.addNode();
hegyi@677:       EPGr2.addNode();
hegyi@677:       printf("%d node is in EPGr2 after addition of 2 more nodes.\n", EPGr2.nodeNum());
hegyi@677: 
hegyi@677:       printf("%d nodes are in EPGr, before clear.\n", EPGr.nodeNum());
hegyi@677:       EPGr.clear();
hegyi@677:       printf("%d nodes are in EPGr, after clear.\n", EPGr.nodeNum());
hegyi@677:       printf("%d nodes are in EPGr2, after clear of EPGr.\n", EPGr2.nodeNum());
hegyi@677:       EPGr2.clear();
hegyi@677:   }
hegyi@677:   {
hegyi@677:       EdgePathGraph<DirPath<ListGraph>, SmartGraph, ListGraph> EPGr;
hegyi@677:       //EdgePathGraph<DirPath<ListGraph>, SmartGraph, EdgePathGraph<DirPath<SmartGraph>, ListGraph, SmartGraph> > EPGr;
hegyi@677:       EdgePathGraph<DirPath<SmartGraph>, ListGraph, SmartGraph> EPGr2;
hegyi@677:    
hegyi@677:       typedef EdgePathGraph<DirPath<SmartGraph>, SmartGraph, ListGraph>::Node Node;
hegyi@677:       typedef EdgePathGraph<DirPath<SmartGraph>, SmartGraph, ListGraph>::Edge Edge;
hegyi@677:       typedef EdgePathGraph<DirPath<SmartGraph>, SmartGraph, ListGraph>::EdgeIt EdgeIt;
hegyi@677: 
hegyi@677:       Node n0, n1, n2;
hegyi@677:       Edge e0, e1, e2, e3, e4, e5;
hegyi@677: 
hegyi@677:       ListGraph::Node m0, m1, m2, m3;
hegyi@677:       ListGraph::Edge f0, f1, f2, f3, f4, f5;
hegyi@677: 
hegyi@677: 
hegyi@677:       n0=EPGr.addNode();
hegyi@677:       n1=EPGr.addNode();
hegyi@677:       n2=EPGr.addNode();
hegyi@677: 
hegyi@677:       e0=EPGr.addEdge(n0,n1);
hegyi@677:       e1=EPGr.addEdge(n1,n0);
hegyi@677:       e2=EPGr.addEdge(n0,n2);
hegyi@677:       e3=EPGr.addEdge(n2,n0);
hegyi@677:       e4=EPGr.addEdge(n1,n2);
hegyi@677:       e5=EPGr.addEdge(n2,n1);
hegyi@677: 
hegyi@677: 
hegyi@677:       m0=EPGr2.addNode();
hegyi@677:       m1=EPGr2.addNode();
hegyi@677:       m2=EPGr2.addNode();
hegyi@677:       m3=EPGr2.addNode();
hegyi@677:     
hegyi@677:       f0=EPGr2.addEdge(m0,m3);
hegyi@677:       f1=EPGr2.addEdge(m3,m0);
hegyi@677:       f2=EPGr2.addEdge(m2,m3);
hegyi@677:       f3=EPGr2.addEdge(m3,m2);
hegyi@677:       f4=EPGr2.addEdge(m1,m2);
hegyi@677:       f5=EPGr2.addEdge(m2,m1);
hegyi@677: 
hegyi@677:       EPGr.sublayer=&(EPGr2.actuallayer);
hegyi@677:       //EPGr.sublayer=&(EPGr2);
hegyi@677:     
hegyi@677:       EPGr.projection[n0]=&m0;
hegyi@677:       EPGr.projection[n1]=&m1;
hegyi@677:       EPGr.projection[n2]=&m2;
hegyi@677: 
hegyi@677:       
hegyi@677:       typedef DirPath<ListGraph> DPath;
hegyi@677: 
hegyi@677:       //DPath P(EPGr2);
hegyi@677: 
hegyi@677:       DPath P1(EPGr2.actuallayer);//0-2
hegyi@677:       DPath::Builder B1(P1);
hegyi@677:       B1.pushBack(f0);
hegyi@677:       B1.pushBack(f3);
hegyi@677:       B1.commit();
hegyi@677:       cout << P1.length() << " hosszu utvonal letrehozva" << endl;
hegyi@677: 
hegyi@677:       DPath P2(EPGr2.actuallayer);//2-0
hegyi@677:       DPath::Builder B2(P2);
hegyi@677:       B2.pushBack(f2);
hegyi@677:       B2.pushBack(f1);
hegyi@677:       B2.commit();
hegyi@677:       cout << P2.length() << " hosszu utvonal letrehozva" << endl;
hegyi@677: 
hegyi@677:       DPath P3(EPGr2.actuallayer);//0-1
hegyi@677:       DPath::Builder B3(P3);
hegyi@677:       B3.pushBack(f0);
hegyi@677:       B3.pushBack(f3);
hegyi@677:       B3.pushBack(f5);
hegyi@677:       B3.commit();
hegyi@677:       cout << P3.length() << " hosszu utvonal letrehozva" << endl;
hegyi@677: 
hegyi@677:       DPath P4(EPGr2.actuallayer);//1-0
hegyi@677:       DPath::Builder B4(P4);
hegyi@677:       B4.pushBack(f4);
hegyi@677:       B4.pushBack(f2);
hegyi@677:       B4.pushBack(f1);
hegyi@677:       B4.commit();
hegyi@677:       cout << P4.length() << " hosszu utvonal letrehozva" << endl;
hegyi@677: 
hegyi@677: 
hegyi@677:       EPGr.edgepath[e0]=&P3;
hegyi@677:       EPGr.edgepath[e1]=&P4;
hegyi@677:       EPGr.edgepath[e2]=&P1;
hegyi@677:       EPGr.edgepath[e3]=&P2;
hegyi@677: 
hegyi@677:       for(EdgeIt e(EPGr.actuallayer);EPGr.actuallayer.valid(e);EPGr.actuallayer.next(e))
hegyi@677:       {
hegyi@677: 	typedef DPath::EdgeIt PEdgeIt;
hegyi@677: 	PEdgeIt f;
hegyi@677: 
hegyi@677: 	cout << "Edge " << EPGr.id(EPGr.tail(e)) << " - " << EPGr.id(EPGr.head(e)) << " in actual layer is";
hegyi@677:         if(EPGr.edgepath[e])
hegyi@677: 	{
hegyi@677: 	  cout << endl << "Path";
hegyi@677: 	  for(EPGr.edgepath[e]->first(f); EPGr.edgepath[e]->valid(f); EPGr.edgepath[e]->next(f))
hegyi@677: 	  {
hegyi@677: 	    cout << " " << EPGr2.id(EPGr2.tail(f)) << "-" << EPGr2.id(EPGr2.head(f));
hegyi@677: 	  }
hegyi@677: 	  //cout << EPGr2.id(EPGr2.head(f)) << endl;
hegyi@677: 	  cout << endl;
hegyi@677: 	}
hegyi@677: 	else
hegyi@677: 	{
hegyi@677: 	  cout << " itself." <<endl;
hegyi@677: 	}
hegyi@677:       }
hegyi@677:     
hegyi@677: 
hegyi@677:       cout << "================================" << endl;
hegyi@677:     
hegyi@677:       SmartGraph::EdgeMap<int> actlaymap(EPGr.actuallayer);
hegyi@677:       //EdgePathGraph<DirPath<ListGraph>, SmartGraph, EdgePathGraph<DirPath<SmartGraph>, ListGraph, SmartGraph> > EPGr;
hegyi@677:       ListGraph::EdgeMap<double> sublaymap(EPGr2.actuallayer);
hegyi@677:       
hegyi@677: 
hegyi@677:       actlaymap[e1]=5;
hegyi@677: 
hegyi@677:       //EdgeMap-ok kiirasa
hegyi@677: 
hegyi@677:       cout << "EdgeMaps before addMap:" << endl;
hegyi@677:     
hegyi@677:       cout << "actlaymap: ";
hegyi@677:       for(EdgeIt e(EPGr.actuallayer);EPGr.actuallayer.valid(e);EPGr.actuallayer.next(e))
hegyi@677:       {
hegyi@677: 	cout << EPGr.id(EPGr.tail(e)) << "-" << EPGr.id(EPGr.head(e)) << ":" << actlaymap[e] << " ";
hegyi@677:       }
hegyi@677:       cout << endl;
hegyi@677:       cout << "sublaymap: ";
hegyi@677:       for(ListGraph::EdgeIt e(EPGr2.actuallayer);EPGr2.actuallayer.valid(e);EPGr2.actuallayer.next(e))
hegyi@677:       {
hegyi@677: 	cout << EPGr2.id(EPGr2.tail(e)) << "-" << EPGr2.id(EPGr2.head(e)) << ":" << sublaymap[e] << " ";
hegyi@677:       }
hegyi@677:       cout << endl;
hegyi@677:       //EdgeMap-ok kiirasa#vege
hegyi@677: 
hegyi@677:       
hegyi@677:       EPGr.addMap<int, double>(actlaymap, sublaymap);
hegyi@677: 
hegyi@677:       //EdgeMap-ok kiirasa
hegyi@677: 
hegyi@677:       cout << "EdgeMaps after addMap:" << endl;
hegyi@677:     
hegyi@677:       cout << "actlaymap: ";
hegyi@677:       for(EdgeIt e(EPGr.actuallayer);EPGr.actuallayer.valid(e);EPGr.actuallayer.next(e))
hegyi@677:       {
hegyi@677: 	cout << EPGr.id(EPGr.tail(e)) << "-" << EPGr.id(EPGr.head(e)) << ":" << actlaymap[e] << " ";
hegyi@677:       }
hegyi@677:       cout << endl;
hegyi@677:       cout << "sublaymap: ";
hegyi@677:       for(ListGraph::EdgeIt e(EPGr2.actuallayer);EPGr2.actuallayer.valid(e);EPGr2.actuallayer.next(e))
hegyi@677:       {
hegyi@677: 	cout << EPGr2.id(EPGr2.tail(e)) << "-" << EPGr2.id(EPGr2.head(e)) << ":" << sublaymap[e] << " ";
hegyi@677:       }
hegyi@677:       cout << endl;
hegyi@677:       //EdgeMap-ok kiirasa#vege
hegyi@677:     
hegyi@677:     
hegyi@677:   }
hegyi@677: }