1.1 --- a/src/work/peter/edgepathgraph_test.cc Sun Apr 17 18:57:22 2005 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,206 +0,0 @@
1.4 -#include <string>
1.5 -#include <iostream>
1.6 -#include <stdio.h>
1.7 -
1.8 -#include "edgepathgraph.h"
1.9 -#include <lemon/list_graph.h>
1.10 -#include <lemon/smart_graph.h>
1.11 -#include <path.h>
1.12 -
1.13 -using namespace lemon;
1.14 -using namespace std;
1.15 -
1.16 -bool passed = true;
1.17 -
1.18 -void check(bool rc) {
1.19 - passed = passed && rc;
1.20 - if(!rc) {
1.21 - cout << "Test failed!" << endl;
1.22 - }
1.23 -}
1.24 -
1.25 -int main()
1.26 -{
1.27 - {
1.28 - EdgePathGraph<DirPath<ListGraph>, SmartGraph, ListGraph> EPGr;
1.29 - EPGr.addNode();
1.30 - EPGr.addNode();
1.31 - EPGr.addNode();
1.32 - EPGr.addNode();
1.33 - printf("%d node is in EPGr, after addition of 4 nodes.\n", EPGr.nodeNum());
1.34 -
1.35 - EdgePathGraph<DirPath<ListGraph>, SmartGraph, ListGraph> EPGr2(EPGr);
1.36 - printf("%d node is in EPGr2 created by copy constructor from EPGr.\n", EPGr2.nodeNum());
1.37 -
1.38 - EPGr2.addNode();
1.39 - EPGr2.addNode();
1.40 - printf("%d node is in EPGr2 after addition of 2 more nodes.\n", EPGr2.nodeNum());
1.41 -
1.42 - printf("%d nodes are in EPGr, before clear.\n", EPGr.nodeNum());
1.43 - EPGr.clear();
1.44 - printf("%d nodes are in EPGr, after clear.\n", EPGr.nodeNum());
1.45 - printf("%d nodes are in EPGr2, after clear of EPGr.\n", EPGr2.nodeNum());
1.46 - EPGr2.clear();
1.47 - }
1.48 - {
1.49 - EdgePathGraph<DirPath<ListGraph>, SmartGraph, ListGraph> EPGr;
1.50 - //EdgePathGraph<DirPath<ListGraph>, SmartGraph, EdgePathGraph<DirPath<SmartGraph>, ListGraph, SmartGraph> > EPGr;
1.51 - EdgePathGraph<DirPath<SmartGraph>, ListGraph, SmartGraph> EPGr2;
1.52 -
1.53 - typedef EdgePathGraph<DirPath<SmartGraph>, SmartGraph, ListGraph>::Node Node;
1.54 - typedef EdgePathGraph<DirPath<SmartGraph>, SmartGraph, ListGraph>::Edge Edge;
1.55 - typedef EdgePathGraph<DirPath<SmartGraph>, SmartGraph, ListGraph>::EdgeIt EdgeIt;
1.56 -
1.57 - Node n0, n1, n2;
1.58 - Edge e0, e1, e2, e3, e4, e5;
1.59 -
1.60 - ListGraph::Node m0, m1, m2, m3;
1.61 - ListGraph::Edge f0, f1, f2, f3, f4, f5;
1.62 -
1.63 -
1.64 - n0=EPGr.addNode();
1.65 - n1=EPGr.addNode();
1.66 - n2=EPGr.addNode();
1.67 -
1.68 - e0=EPGr.addEdge(n0,n1);
1.69 - e1=EPGr.addEdge(n1,n0);
1.70 - e2=EPGr.addEdge(n0,n2);
1.71 - e3=EPGr.addEdge(n2,n0);
1.72 - e4=EPGr.addEdge(n1,n2);
1.73 - e5=EPGr.addEdge(n2,n1);
1.74 -
1.75 -
1.76 - m0=EPGr2.addNode();
1.77 - m1=EPGr2.addNode();
1.78 - m2=EPGr2.addNode();
1.79 - m3=EPGr2.addNode();
1.80 -
1.81 - f0=EPGr2.addEdge(m0,m3);
1.82 - f1=EPGr2.addEdge(m3,m0);
1.83 - f2=EPGr2.addEdge(m2,m3);
1.84 - f3=EPGr2.addEdge(m3,m2);
1.85 - f4=EPGr2.addEdge(m1,m2);
1.86 - f5=EPGr2.addEdge(m2,m1);
1.87 -
1.88 - EPGr.sublayer=&(EPGr2.actuallayer);
1.89 - //EPGr.sublayer=&(EPGr2);
1.90 -
1.91 - EPGr.projection[n0]=&m0;
1.92 - EPGr.projection[n1]=&m1;
1.93 - EPGr.projection[n2]=&m2;
1.94 -
1.95 -
1.96 - typedef DirPath<ListGraph> DPath;
1.97 -
1.98 - //DPath P(EPGr2);
1.99 -
1.100 - DPath P1(EPGr2.actuallayer);//0-2
1.101 - DPath::Builder B1(P1);
1.102 - B1.pushBack(f0);
1.103 - B1.pushBack(f3);
1.104 - B1.commit();
1.105 - cout << P1.length() << " hosszu utvonal letrehozva" << endl;
1.106 -
1.107 - DPath P2(EPGr2.actuallayer);//2-0
1.108 - DPath::Builder B2(P2);
1.109 - B2.pushBack(f2);
1.110 - B2.pushBack(f1);
1.111 - B2.commit();
1.112 - cout << P2.length() << " hosszu utvonal letrehozva" << endl;
1.113 -
1.114 - DPath P3(EPGr2.actuallayer);//0-1
1.115 - DPath::Builder B3(P3);
1.116 - B3.pushBack(f0);
1.117 - B3.pushBack(f3);
1.118 - B3.pushBack(f5);
1.119 - B3.commit();
1.120 - cout << P3.length() << " hosszu utvonal letrehozva" << endl;
1.121 -
1.122 - DPath P4(EPGr2.actuallayer);//1-0
1.123 - DPath::Builder B4(P4);
1.124 - B4.pushBack(f4);
1.125 - B4.pushBack(f2);
1.126 - B4.pushBack(f1);
1.127 - B4.commit();
1.128 - cout << P4.length() << " hosszu utvonal letrehozva" << endl;
1.129 -
1.130 -
1.131 - EPGr.edgepath[e0]=&P3;
1.132 - EPGr.edgepath[e1]=&P4;
1.133 - EPGr.edgepath[e2]=&P1;
1.134 - EPGr.edgepath[e3]=&P2;
1.135 -
1.136 - for(EdgeIt e(EPGr.actuallayer);EPGr.actuallayer.valid(e);EPGr.actuallayer.next(e))
1.137 - {
1.138 - typedef DPath::EdgeIt PEdgeIt;
1.139 - PEdgeIt f;
1.140 -
1.141 - cout << "Edge " << EPGr.id(EPGr.source(e)) << " - " << EPGr.id(EPGr.target(e)) << " in actual layer is";
1.142 - if(EPGr.edgepath[e])
1.143 - {
1.144 - cout << endl << "Path";
1.145 - for(EPGr.edgepath[e]->first(f); EPGr.edgepath[e]->valid(f); EPGr.edgepath[e]->next(f))
1.146 - {
1.147 - cout << " " << EPGr2.id(EPGr2.source(f)) << "-" << EPGr2.id(EPGr2.target(f));
1.148 - }
1.149 - //cout << EPGr2.id(EPGr2.target(f)) << endl;
1.150 - cout << endl;
1.151 - }
1.152 - else
1.153 - {
1.154 - cout << " itself." <<endl;
1.155 - }
1.156 - }
1.157 -
1.158 -
1.159 - cout << "================================" << endl;
1.160 -
1.161 - SmartGraph::EdgeMap<int> actlaymap(EPGr.actuallayer);
1.162 - //EdgePathGraph<DirPath<ListGraph>, SmartGraph, EdgePathGraph<DirPath<SmartGraph>, ListGraph, SmartGraph> > EPGr;
1.163 - ListGraph::EdgeMap<double> sublaymap(EPGr2.actuallayer);
1.164 -
1.165 -
1.166 - actlaymap[e1]=5;
1.167 -
1.168 - //EdgeMap-ok kiirasa
1.169 -
1.170 - cout << "EdgeMaps before addMap:" << endl;
1.171 -
1.172 - cout << "actlaymap: ";
1.173 - for(EdgeIt e(EPGr.actuallayer);EPGr.actuallayer.valid(e);EPGr.actuallayer.next(e))
1.174 - {
1.175 - cout << EPGr.id(EPGr.source(e)) << "-" << EPGr.id(EPGr.target(e)) << ":" << actlaymap[e] << " ";
1.176 - }
1.177 - cout << endl;
1.178 - cout << "sublaymap: ";
1.179 - for(ListGraph::EdgeIt e(EPGr2.actuallayer);EPGr2.actuallayer.valid(e);EPGr2.actuallayer.next(e))
1.180 - {
1.181 - cout << EPGr2.id(EPGr2.source(e)) << "-" << EPGr2.id(EPGr2.target(e)) << ":" << sublaymap[e] << " ";
1.182 - }
1.183 - cout << endl;
1.184 - //EdgeMap-ok kiirasa#vege
1.185 -
1.186 -
1.187 - EPGr.addMap<int, double>(actlaymap, sublaymap);
1.188 -
1.189 - //EdgeMap-ok kiirasa
1.190 -
1.191 - cout << "EdgeMaps after addMap:" << endl;
1.192 -
1.193 - cout << "actlaymap: ";
1.194 - for(EdgeIt e(EPGr.actuallayer);EPGr.actuallayer.valid(e);EPGr.actuallayer.next(e))
1.195 - {
1.196 - cout << EPGr.id(EPGr.source(e)) << "-" << EPGr.id(EPGr.target(e)) << ":" << actlaymap[e] << " ";
1.197 - }
1.198 - cout << endl;
1.199 - cout << "sublaymap: ";
1.200 - for(ListGraph::EdgeIt e(EPGr2.actuallayer);EPGr2.actuallayer.valid(e);EPGr2.actuallayer.next(e))
1.201 - {
1.202 - cout << EPGr2.id(EPGr2.source(e)) << "-" << EPGr2.id(EPGr2.target(e)) << ":" << sublaymap[e] << " ";
1.203 - }
1.204 - cout << endl;
1.205 - //EdgeMap-ok kiirasa#vege
1.206 -
1.207 -
1.208 - }
1.209 -}