hegyi@677: // -*- c++ -*- hegyi@677: #ifndef HUGO_NET_GRAPH_H hegyi@677: #define HUGO_NET_GRAPH_H hegyi@677: hegyi@677: ///\file hegyi@677: ///\brief Declaration of EdgePathGraph. hegyi@677: hegyi@677: #include hegyi@677: #include hegyi@677: hegyi@677: /// The namespace of HugoLib hegyi@677: namespace hugo { hegyi@677: hegyi@677: // @defgroup empty_graph The EdgePathGraph class hegyi@677: // @{ hegyi@677: hegyi@677: /// A graph class in that a simple edge can represent a path. hegyi@677: hegyi@677: /// This class provides all the common features of a graph structure hegyi@677: /// that represents a network. You can handle with it layers. This hegyi@677: /// means that an edge in one layer can be a complete path in a nother hegyi@677: /// layer. hegyi@677: hegyi@677: template hegyi@677: class EdgePathGraph hegyi@677: { hegyi@677: hegyi@677: public: hegyi@677: hegyi@677: /// The actual layer hegyi@677: Gact actuallayer; hegyi@677: hegyi@677: hegyi@677: /// The layer on which the edges in this layer can represent paths. hegyi@677: Gsub * sublayer; hegyi@677: hegyi@677: hegyi@677: /// Map of nodes that represent the nodes of this layer in the sublayer hegyi@677: typename Gact::template NodeMap projection; hegyi@677: hegyi@677: hegyi@677: /// Map of routes that are represented by some edges in this layer hegyi@677: typename Gact::template EdgeMap

edgepath; hegyi@677: hegyi@677: hegyi@677: /// Defalult constructor. hegyi@677: /// We don't need any extra lines, because the actuallayer hegyi@677: /// variable has run its constructor, when we have created this class hegyi@677: /// So only the two maps has to be initialised here. hegyi@677: EdgePathGraph() : projection(actuallayer), edgepath(actuallayer) hegyi@677: { hegyi@677: } hegyi@677: hegyi@677: hegyi@677: ///Copy consructor. hegyi@677: EdgePathGraph(const EdgePathGraph & EPG ) : actuallayer(EPG.actuallayer) , edgepath(actuallayer), projection(actuallayer) hegyi@677: { hegyi@677: } hegyi@677: hegyi@677: hegyi@677: /// Map adder hegyi@677: hegyi@677: /// This function gets two edgemaps. One belongs to the actual layer and the hegyi@677: /// other belongs to the sublayer. hegyi@677: /// The function iterates through all of the edges in the edgemap belonging to the actual layer. hegyi@677: /// It gets the value that belongs to the actual edge, and adds it to the value of each edge in the hegyi@677: /// path represented by itself in the edgemap that belongs to the sublayer. hegyi@677: hegyi@677: template void addMap (typename Gact::EdgeMap & actmap, typename Gsub::EdgeMap & submap) hegyi@677: { hegyi@677: for(EdgeIt e(actuallayer);actuallayer.valid(e);actuallayer.next(e)) hegyi@677: { hegyi@677: typedef typename P::EdgeIt PEdgeIt; hegyi@677: PEdgeIt f; hegyi@677: hegyi@677: //dep//cout << "Edge " << id(tail(e)) << " - " << id(head(e)) << " in actual layer is"; hegyi@677: T1 incr=actmap[e]; hegyi@677: //cout << incr << endl; hegyi@677: hegyi@677: if(edgepath[e]) hegyi@677: { hegyi@677: //dep//cout << endl << "Path"; hegyi@677: for(edgepath[e]->first(f); edgepath[e]->valid(f); edgepath[e]->next(f)) hegyi@677: { hegyi@677: //dep//cout << " " << sublayer->id(sublayer->tail(f)) << "-" << sublayer->id(sublayer->head(f)); hegyi@677: submap[f]+=incr; hegyi@677: } hegyi@677: //dep////cout << EPGr2.id(EPGr2.head(f)) << endl; hegyi@677: //dep//cout << endl; hegyi@677: } hegyi@677: else hegyi@677: { hegyi@677: //dep//cout << " itself." <first(f); edgepath[e]->valid(f); edgepath[e]->next(f)) hegyi@677: { hegyi@677: cout << " " << sublayer->id(sublayer->tail(f)) << "-" << sublayer->id(sublayer->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." <) hegyi@677: /// needs extra attention! hegyi@677: hegyi@677: template class NodeMap hegyi@677: { hegyi@677: public: hegyi@677: typedef T ValueType; hegyi@677: typedef Node KeyType; hegyi@677: hegyi@677: NodeMap(const EdgePathGraph &) {} hegyi@677: NodeMap(const EdgePathGraph &, T) {} hegyi@677: hegyi@677: template NodeMap(const NodeMap &) {} hegyi@677: hegyi@677: /// Sets the value of a node. hegyi@677: hegyi@677: /// Sets the value associated with node \c i to the value \c t. hegyi@677: /// hegyi@677: void set(Node, T) {} hegyi@677: // Gets the value of a node. hegyi@677: //T get(Node i) const {return *(T*)0;} //FIXME: Is it necessary? hegyi@677: T &operator[](Node) {return *(T*)0;} hegyi@677: const T &operator[](Node) const {return *(T*)0;} hegyi@677: hegyi@677: /// Updates the map if the graph has been changed hegyi@677: hegyi@677: /// \todo Do we need this? hegyi@677: /// hegyi@677: void update() {} hegyi@677: void update(T a) {} //FIXME: Is it necessary hegyi@677: }; hegyi@677: hegyi@677: ///Read/write/reference map of the edges to type \c T. hegyi@677: hegyi@677: ///Read/write/reference map of the edges to type \c T. hegyi@677: ///It behaves exactly in the same way as \ref NodeMap. hegyi@677: /// \sa NodeMap hegyi@677: /// \sa MemoryMapSkeleton hegyi@677: /// \todo We may need copy constructor hegyi@677: /// \todo We may need conversion from other edgetype hegyi@677: /// \todo We may need operator= hegyi@677: template class EdgeMap hegyi@677: { hegyi@677: public: hegyi@677: typedef T ValueType; hegyi@677: typedef Edge KeyType; hegyi@677: hegyi@677: EdgeMap(const EdgePathGraph &) {} hegyi@677: EdgeMap(const EdgePathGraph &, T ) {} hegyi@677: hegyi@677: ///\todo It can copy between different types. hegyi@677: /// hegyi@677: template EdgeMap(const EdgeMap &) {} hegyi@677: hegyi@677: void set(Edge, T) {} hegyi@677: //T get(Edge) const {return *(T*)0;} hegyi@677: T &operator[](Edge) {return *(T*)0;} hegyi@677: const T &operator[](Edge) const {return *(T*)0;} hegyi@677: hegyi@677: void update() {} hegyi@677: void update(T a) {} //FIXME: Is it necessary hegyi@677: }; hegyi@677: }; hegyi@677: alpar@826: /// An empty erasable graph class. hegyi@677: alpar@826: /// This class provides all the common features of an \e erasable graph hegyi@677: /// structure, hegyi@677: /// however completely without implementations and real data structures hegyi@677: /// behind the interface. hegyi@677: /// All graph algorithms should compile with this class, but it will not hegyi@677: /// run properly, of course. hegyi@677: /// hegyi@677: /// \todo This blabla could be replaced by a sepatate description about hegyi@677: /// Skeletons. hegyi@677: /// hegyi@677: /// It can be used for checking the interface compatibility, hegyi@677: /// or it can serve as a skeleton of a new graph structure. hegyi@677: /// hegyi@677: /// Also, you will find here the full documentation of a certain graph hegyi@677: /// feature, the documentation of a real graph imlementation hegyi@677: /// like @ref ListGraph or hegyi@677: /// @ref SmartGraph will just refer to this structure. hegyi@677: template alpar@826: class ErasableEdgePathGraph : public EdgePathGraph hegyi@677: { hegyi@677: public: hegyi@677: /// Deletes a node. hegyi@677: void erase(typename Gact::Node n) {actuallayer.erase(n);} hegyi@677: /// Deletes an edge. hegyi@677: void erase(typename Gact::Edge e) {actuallayer.erase(e);} hegyi@677: hegyi@677: /// Defalult constructor. alpar@826: ErasableEdgePathGraph() {} hegyi@677: ///Copy consructor. alpar@826: ErasableEdgePathGraph(const EdgePathGraph &EPG) {} hegyi@677: }; hegyi@677: hegyi@677: hegyi@677: // @} hegyi@677: hegyi@677: } //namespace hugo hegyi@677: hegyi@677: hegyi@677: #endif // HUGO_SKELETON_GRAPH_H