1.1 --- a/src/work/peter/Makefile Wed Jun 30 14:59:46 2004 +0000
1.2 +++ b/src/work/peter/Makefile Mon Jul 05 15:52:35 2004 +0000
1.3 @@ -1,5 +1,6 @@
1.4 +hier: hierarchygraph.h hierarchygraph_test.cc
1.5 + g++ -Wall -W -I../.. -I../klao -I../../hugo hierarchygraph_test.cc -o test
1.6 +
1.7 edge: edgepathgraph_test.cc edgepathgraph.h
1.8 - g++ -I../.. -I../klao -I../../hugo edgepathgraph_test.cc -o test
1.9 + g++ -Wall -W -I../.. -I../klao -I../../hugo edgepathgraph_test.cc -o test
1.10
1.11 -hier: hierarchygraph.h hierarchygraph_test.cc
1.12 - g++ -I../.. -I../klao -I../../hugo hierarchygraph_test.cc -o test
2.1 --- a/src/work/peter/hierarchygraph.h Wed Jun 30 14:59:46 2004 +0000
2.2 +++ b/src/work/peter/hierarchygraph.h Mon Jul 05 15:52:35 2004 +0000
2.3 @@ -15,7 +15,7 @@
2.4 // @{
2.5
2.6 /// A graph class in that a simple edge can represent a path.
2.7 -
2.8 +
2.9 /// This class provides common features of a graph structure
2.10 /// that represents a network. You can handle with it layers. This
2.11 /// means that a node in one layer can be a complete network in a nother
2.12 @@ -31,26 +31,150 @@
2.13 Gact actuallayer;
2.14
2.15
2.16 - /// Map of subnetworks that are represented by the nodes of this layer
2.17 - typename Gact::template NodeMap<Gsub> subnetwork;
2.18 + /// Map of the subnetworks in the sublayer
2.19 + /// The appropriate edge nodes are also stored here
2.20
2.21 + class SubNetwork
2.22 + {
2.23 +
2.24 + struct actedgesubnodestruct
2.25 + {
2.26 + typename Gact::Edge actedge;
2.27 + typename Gsub::Node subnode;
2.28 + };
2.29 +
2.30 + int edgenumber;
2.31 + bool connectable;
2.32 + Gact * actuallayer;
2.33 + typename Gact::Node * actuallayernode;
2.34 + Gsub * subnetwork;
2.35 + actedgesubnodestruct * assignments;
2.36 +
2.37 + public:
2.38 +
2.39 + int addAssignment(typename Gact::Edge actedge, typename Gsub::Node subnode)
2.40 + {
2.41 + if(!(actuallayer->valid(actedge)))
2.42 + {
2.43 + cerr << "The given edge is not in the given network!" << endl;
2.44 + return -1;
2.45 + }
2.46 + else if(
2.47 + (actuallayer->id(actuallayer->tail(actedge))!=actuallayer->id(*actuallayernode))
2.48 + &&
2.49 + (actuallayer->id(actuallayer->head(actedge))!=actuallayer->id(*actuallayernode))
2.50 + )
2.51 + {
2.52 + cerr << "The given edge does not connect to the given node!" << endl;
2.53 + return -1;
2.54 + }
2.55 +
2.56 + if(!(subnetwork->valid(subnode)))
2.57 + {
2.58 + cerr << "The given node is not in the given network!" << endl;
2.59 + return -1;
2.60 + }
2.61 +
2.62 + int i=0;
2.63 + //while in the array there is valid note that is not equvivalent with the one that would be noted increase i
2.64 + while( (i<edgenumber) && (actuallayer->valid(assignments[i].actedge) ) && (assignments[i].actedge!=actedge) ) i++;
2.65 + if(assignments[i].actedge==actedge)
2.66 + {
2.67 + cout << "Warning: Redefinement of assigment!!!" << endl;
2.68 + }
2.69 + if(i==edgenumber)
2.70 + {
2.71 + cout << "This case can't be!!! (because there should be the guven edge in the array already and the cycle had to stop)" << endl;
2.72 + }
2.73 + //if(!(actuallayer->valid(assignments[i].actedge))) //this condition is necessary if we do not obey redefinition
2.74 + {
2.75 + assignments[i].actedge=actedge;
2.76 + assignments[i].subnode=subnode;
2.77 + }
2.78 +
2.79 + /// If to all of the edges a subnode is assigned then the subnetwork is connectable (attachable?)
2.80 + /// We do not need to check for further attributes, because to notice an assignment we need
2.81 + /// all of them to be correctly initialised before.
2.82 + if(i==edgenumber-1)connectable=1;
2.83 +
2.84 + return 0;
2.85 + }
2.86 +
2.87 + int setSubNetwork(Gsub * sn)
2.88 + {
2.89 + subnetwork=sn;
2.90 + return 0;
2.91 + }
2.92 +
2.93 + int setActualLayer(Gact * al)
2.94 + {
2.95 + actuallayer=al;
2.96 + return 0;
2.97 + }
2.98 +
2.99 + int setActualLayerNode(typename Gact::Node * aln)
2.100 + {
2.101 + typename Gact::InEdgeIt iei;
2.102 + typename Gact::OutEdgeIt oei;
2.103 +
2.104 + actuallayernode=aln;
2.105 +
2.106 + edgenumber=0;
2.107 +
2.108 + if(actuallayer)
2.109 + {
2.110 + for(iei=actuallayer->first(iei,(*actuallayernode));((actuallayer->valid(iei))&&(actuallayer->head(iei)==(*actuallayernode)));actuallayer->next(iei))
2.111 + {
2.112 + cout << actuallayer->id(actuallayer->tail(iei)) << " " << actuallayer->id(actuallayer->head(iei)) << endl;
2.113 + edgenumber++;
2.114 + }
2.115 + //cout << "Number of in-edges: " << edgenumber << endl;
2.116 + for(oei=actuallayer->first(oei,(*actuallayernode));((actuallayer->valid(oei))&&(actuallayer->tail(oei)==(*actuallayernode)));actuallayer->next(oei))
2.117 + {
2.118 + cout << actuallayer->id(actuallayer->tail(oei)) << " " << actuallayer->id(actuallayer->head(oei)) << endl;
2.119 + edgenumber++;
2.120 + }
2.121 + //cout << "Number of in+out-edges: " << edgenumber << endl;
2.122 + assignments=new actedgesubnodestruct[edgenumber];
2.123 + for(int i=0;i<edgenumber;i++)
2.124 + {
2.125 + assignments[i].actedge=INVALID;
2.126 + assignments[i].subnode=INVALID;
2.127 + }
2.128 + }
2.129 + else
2.130 + {
2.131 + cerr << "There is no actual layer defined yet!" << endl;
2.132 + return -1;
2.133 + }
2.134 +
2.135 + return 0;
2.136 + }
2.137 +
2.138 + SubNetwork(): edgenumber(0), connectable(false), actuallayer(NULL), actuallayernode(NULL), subnetwork(NULL), assignments(NULL)
2.139 + {
2.140 + }
2.141 +
2.142 + };
2.143 +
2.144 + typename Gact::template NodeMap< SubNetwork > subnetworks;
2.145
2.146
2.147 /// Defalult constructor.
2.148 /// We don't need any extra lines, because the actuallayer
2.149 /// variable has run its constructor, when we have created this class
2.150 /// So only the two maps has to be initialised here.
2.151 - HierarchyGraph() : subnetwork(actuallayer)
2.152 + HierarchyGraph() : subnetworks(actuallayer)
2.153 {
2.154 }
2.155
2.156
2.157 ///Copy consructor.
2.158 - HierarchyGraph(const HierarchyGraph<Gact, Gsub> & HG ) : actuallayer(HG.actuallayer), subnetwork(actuallayer)
2.159 + HierarchyGraph(const HierarchyGraph<Gact, Gsub> & HG ) : actuallayer(HG.actuallayer), subnetworks(actuallayer)
2.160 {
2.161 }
2.162
2.163 -
2.164 +
2.165 /// The base type of the node iterators.
2.166
2.167 /// This is the base type of each node iterators,
2.168 @@ -58,7 +182,7 @@
2.169 /// The Node type of the HierarchyGraph is the Node type of the actual layer.
2.170 typedef typename Gact::Node Node;
2.171
2.172 -
2.173 +
2.174 /// This iterator goes through each node.
2.175
2.176 /// Its usage is quite simple, for example you can count the number
2.177 @@ -69,13 +193,13 @@
2.178 /// \endcode
2.179 /// The NodeIt type of the HierarchyGraph is the NodeIt type of the actual layer.
2.180 typedef typename Gact::NodeIt NodeIt;
2.181 -
2.182 -
2.183 +
2.184 +
2.185 /// The base type of the edge iterators.
2.186 /// The Edge type of the HierarchyGraph is the Edge type of the actual layer.
2.187 typedef typename Gact::Edge Edge;
2.188
2.189 -
2.190 +
2.191 /// This iterator goes trough the outgoing edges of a node.
2.192
2.193 /// This iterator goes trough the \e outgoing edges of a certain node
2.194 @@ -160,7 +284,7 @@
2.195 typename Gact::Node head(typename Gact::Edge edge) const { return actuallayer.head(edge); }
2.196 ///Gives back the tail node of an edge.
2.197 typename Gact::Node tail(typename Gact::Edge edge) const { return actuallayer.tail(edge); }
2.198 -
2.199 +
2.200 // Node aNode(InEdgeIt) const {}
2.201 // Node aNode(OutEdgeIt) const {}
2.202 // Node aNode(SymEdgeIt) const {}
2.203 @@ -193,7 +317,7 @@
2.204
2.205 //void setInvalid(Node &) const {};
2.206 //void setInvalid(Edge &) const {};
2.207 -
2.208 +
2.209 ///Add a new node to the graph.
2.210
2.211 /// \return the new node.
2.212 @@ -205,7 +329,7 @@
2.213 ///and head node \c head.
2.214 ///\return the new edge.
2.215 typename Gact::Edge addEdge(typename Gact::Node node1, typename Gact::Node node2) { return actuallayer.addEdge(node1, node2);}
2.216 -
2.217 +
2.218 /// Resets the graph.
2.219
2.220 /// This function deletes all edges and nodes of the graph.
2.221 @@ -271,7 +395,7 @@
2.222
2.223 EdgeMap(const HierarchyGraph &) {}
2.224 EdgeMap(const HierarchyGraph &, T ) {}
2.225 -
2.226 +
2.227 ///\todo It can copy between different types.
2.228 ///
2.229 template<typename TT> EdgeMap(const EdgeMap<TT> &) {}
2.230 @@ -280,14 +404,14 @@
2.231 //T get(Edge) const {return *(T*)0;}
2.232 T &operator[](Edge) {return *(T*)0;}
2.233 const T &operator[](Edge) const {return *(T*)0;}
2.234 -
2.235 +
2.236 void update() {}
2.237 void update(T a) {} //FIXME: Is it necessary
2.238 };
2.239 };
2.240
2.241 /// An empty eraseable graph class.
2.242 -
2.243 +
2.244 /// This class provides all the common features of an \e eraseable graph
2.245 /// structure,
2.246 /// however completely without implementations and real data structures
2.247 @@ -300,7 +424,7 @@
2.248 ///
2.249 /// It can be used for checking the interface compatibility,
2.250 /// or it can serve as a skeleton of a new graph structure.
2.251 - ///
2.252 + ///
2.253 /// Also, you will find here the full documentation of a certain graph
2.254 /// feature, the documentation of a real graph imlementation
2.255 /// like @ref ListGraph or
2.256 @@ -320,7 +444,7 @@
2.257 EraseableHierarchyGraph(const HierarchyGraph<Gact, Gsub> &EPG) {}
2.258 };
2.259
2.260 -
2.261 +
2.262 // @}
2.263
2.264 } //namespace hugo
3.1 --- a/src/work/peter/hierarchygraph_test.cc Wed Jun 30 14:59:46 2004 +0000
3.2 +++ b/src/work/peter/hierarchygraph_test.cc Mon Jul 05 15:52:35 2004 +0000
3.3 @@ -22,4 +22,68 @@
3.4 int main()
3.5 {
3.6 HierarchyGraph<SmartGraph, ListGraph> HGr;
3.7 + ListGraph subnetwork, othernetwork;
3.8 + typedef HierarchyGraph<SmartGraph, ListGraph>::Node Node;
3.9 + typedef HierarchyGraph<SmartGraph, ListGraph>::Edge Edge;
3.10 + typedef HierarchyGraph<SmartGraph, ListGraph>::SubNetwork Sntype;
3.11 +
3.12 + Node n0, n1, n2;
3.13 + Edge e0, e1, e2, e3, e4, e5;
3.14 +
3.15 + ListGraph::Node sn0, sn1, on0;
3.16 + ListGraph::Edge se0;
3.17 +
3.18 + n0=HGr.addNode();
3.19 +
3.20 + cout << "Az n0 id-je: " << HGr.actuallayer.id(n0) << endl;
3.21 +
3.22 + n1=HGr.addNode();
3.23 + n2=HGr.addNode();
3.24 +
3.25 + e0=HGr.addEdge(n0,n1);
3.26 + e1=HGr.addEdge(n1,n0);
3.27 + e2=HGr.addEdge(n0,n2);
3.28 + e3=HGr.addEdge(n2,n0);
3.29 + e4=HGr.addEdge(n1,n2);
3.30 + e5=HGr.addEdge(n2,n1);
3.31 +
3.32 + sn0=subnetwork.addNode();
3.33 + sn1=subnetwork.addNode();
3.34 + se0=subnetwork.addEdge(sn0,sn1);
3.35 +
3.36 + Sntype sn;
3.37 + sn.setActualLayer(&(HGr.actuallayer));
3.38 + sn.setActualLayerNode(&(n0));
3.39 + sn.addAssignment(e0, sn0);
3.40 + sn.addAssignment(e1, sn1);
3.41 + sn.addAssignment(e2, sn1);
3.42 + sn.addAssignment(e3, sn0);
3.43 + sn.addAssignment(e1, sn0);
3.44 + sn.addAssignment(e5, sn0);
3.45 +
3.46 +
3.47 +
3.48 + on0=othernetwork.addNode();
3.49 +
3.50 + cout << "ID of a node from a different graph: " << subnetwork.id(on0) << endl;
3.51 + cout << "ID of a node in its graph: " << othernetwork.id(on0) << endl;
3.52 + cout << "ID of a node from a graph: " << subnetwork.id(sn0) << endl;
3.53 +
3.54 + ListGraph::NodeIt snni;
3.55 + //ListGraph::Node snn;
3.56 +
3.57 + for(subnetwork.first(snni);subnetwork.valid(snni);subnetwork.next(snni))
3.58 + {
3.59 + if(snni==on0)
3.60 + {
3.61 + cout << "Nem jo, megtalalta az idegen node-ot sajat haloban, pedig azt nem szabad!!!"
3.62 + << subnetwork.id(snni) << subnetwork.id(on0) << othernetwork.id(snni) << othernetwork.id(on0) << endl;
3.63 + }
3.64 + else cout << "ID:" << subnetwork.id(snni) << endl;
3.65 +
3.66 + }
3.67 +
3.68 +
3.69 + HGr.subnetworks[n0]=sn;
3.70 +
3.71 }
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/src/work/peter/remarks Mon Jul 05 15:52:35 2004 +0000
4.3 @@ -0,0 +1,63 @@
4.4 +-hogy lehet elerni, hogy mindig minden fv-t forditson le, ne csak
4.5 + szintaktikailag ellenorizze?
4.6 +
4.7 +-mennyi adatot taroljunk? taroljunk, vagy szarmaztassunk? pl gondolok
4.8 + itt a ki, illetve a bemeno elek szamara, adott aktualis retegbeli
4.9 + csomopont szamara.
4.10 + -hmm. inkabb megis globalis legyen az edgenumber, mert fontos? hogyan
4.11 + lehet vedeni az utolagos belepiszkalas ellen?
4.12 +
4.13 +-vedelmet berakni?
4.14 + -az adatmezo olvashato legyen, de irhato ne
4.15 + -a beiro fv. csak egyszer legyen hivhato
4.16 +
4.17 +
4.18 +-subnetworkbe kell a perem csomopontokba el? mert szerintem nem. azt
4.19 + ugyis bejeloltuk, hogy az peremcsomopont. csak azt hogy jeloljuk, hogy melyik
4.20 + elhez tartozik?
4.21 +-egy subnetworkbeli csomoponthoz tartozhat
4.22 + -tobb be/ki meno el?
4.23 + -egyszerre kimeno is, meg bemeno is?
4.24 +-szerintem csak az a megkotes kell, hogy egy elhez egy csp tartozzon
4.25 + -miert ne lehetne, hogy egy peremcspba tobb el van bekotve?
4.26 +
4.27 +
4.28 +-nem tudom, es nem is kell, hogy hogyan mukodnek az egyes iteratorok
4.29 + -igy ahhoz, hogy ismerjem az egy pontbol, illetve pontba menoket
4.30 + -egyelore
4.31 + -megadom elsot, ami onnan megy, es addig iteralok, ami onnan
4.32 + van???
4.33 +
4.34 +-van = jel grafoknal?
4.35 + subnetwork=sn;
4.36 +
4.37 +-hogyan tudom kiszamitani a NodeMap elemebol, hogy melyik Nodera
4.38 + vonatkozik?
4.39 + -NodeMap-ben osztaly van
4.40 + -kene, hogy melyik Nodehoz tartozik
4.41 + -most parameterben nyomatom at
4.42 + -de valahogyan csak lehet automatizalni, hogy melyik peldany
4.43 + melyik csphoz van hozzarendelve...
4.44 +
4.45 +-en pointereket hasznalok, nem referenciakat
4.46 +
4.47 +-mivel osztalybol adodik az osztaly, es nem objektumbol, EZERT kell
4.48 + megadni az actuallayert is, ugye jol gondolom?
4.49 +
4.50 +-hmmm. nem kene valami vedelem? tul sok minden fugg tul sokmindentol,
4.51 + osztaly erre valo. de hogy lehet megcsinalni, hogy pl. subnetwork
4.52 + olvashato legyen, de csak fv. irhassa, hogy figyelhessen a
4.53 + valtozasra?
4.54 +
4.55 +-return 0? 1? vagy void?
4.56 +
4.57 +-hogy tudom leellenorizni, hogy adott el/csp eleme-e egy halonak?
4.58 + valid-dal?
4.59 + -na, azzal tuti nem!!!!! de akkor hogyan?
4.60 + -id 0-t ad!!!!!!! (enyemre nyilvanvaloan), ami rendes szam, tehat id-vel sem!!!
4.61 + -nem adja vissza a nodeiterator? aztan annyi? DE VISSZAADJA!
4.62 + -irtam ciklust, mely vegigmegy a node-okon, es osszehasonlitja a
4.63 + egy masik halo node-javal, es egyszercsak kozolte, hogy egyforma!!!
4.64 +
4.65 +-most ugy van, hogy feluldefinialhato az el-csp bejegyzes, ha ugyanazt
4.66 + az elet ketszer adjuk meg. jo ez igy, vagy hibauzenet legyen?
4.67 \ No newline at end of file