diff -r ce74706e924d -r 588ff2ca55bd src/work/marci/leda/leda_graph_wrapper.h --- a/src/work/marci/leda/leda_graph_wrapper.h Thu May 20 09:42:31 2004 +0000 +++ b/src/work/marci/leda/leda_graph_wrapper.h Thu May 20 15:40:59 2004 +0000 @@ -33,10 +33,11 @@ LedaGraphWrapper() : l_graph(0) { } void setGraph(Graph& _l_graph) { l_graph=&_l_graph; } public: - - //LedaGraphWrapper() { } + + /// Constructor for wrapping LEDA graphs. LedaGraphWrapper(Graph& _l_graph) : l_graph(&_l_graph) { } - LedaGraphWrapper(const LedaGraphWrapper &G) : l_graph(G.l_graph) { } + /// Copy constructor + LedaGraphWrapper(const LedaGraphWrapper &g) : l_graph(g.l_graph) { } template class NodeMap; template class EdgeMap; @@ -50,7 +51,7 @@ class OutEdgeIt; class InEdgeIt; - /// The base type of the node iterators. + /// Trivial node-iterator class Node { friend class LedaGraphWrapper; //friend class Edge; @@ -65,7 +66,7 @@ public: /// @warning The default constructor sets the iterator /// to an undefined value. - Node() {} //FIXME + Node() { } //FIXME /// Initialize the iterator to be invalid Node(Invalid) : l_n(0) { } //Node(const Node &) {} @@ -79,15 +80,15 @@ public: /// @warning The default constructor sets the iterator /// to an undefined value. - NodeIt() {} //FIXME + NodeIt() { } //FIXME /// Initialize the iterator to be invalid - NodeIt(Invalid i) : Node(i) {} + NodeIt(Invalid i) : Node(i) { } /// Sets the iterator to the first node of \c G. NodeIt(const LedaGraphWrapper &G) : Node(G.l_graph->first_node()) { } //NodeIt(const NodeIt &) {} //FIXME }; - /// The base type of the edge iterators. + /// Trivial edge-iterator. class Edge { friend class LedaGraphWrapper; protected: @@ -98,24 +99,23 @@ public: /// @warning The default constructor sets the iterator /// to an undefined value. - Edge() {} //FIXME + Edge() { } //FIXME /// Initialize the iterator to be invalid - Edge(Invalid) : l_e(0) {} + Edge(Invalid) : l_e(0) { } //Edge(const Edge &) {} bool operator==(Edge e) const { return l_e==e.l_e; } //FIXME bool operator!=(Edge e) const { return l_e!=e.l_e; } //FIXME operator leda_edge () { return l_e; } }; - /// This iterator goes trought the outgoing edges of a certain graph. - + /// This iterator goes trought the outgoing edges of a certain node. class OutEdgeIt : public Edge { public: /// @warning The default constructor sets the iterator /// to an undefined value. - OutEdgeIt() {} + OutEdgeIt() { } /// Initialize the iterator to be invalid - OutEdgeIt(Invalid i) : Edge(i) {} + OutEdgeIt(Invalid i) : Edge(i) { } /// This constructor sets the iterator to first outgoing edge. /// This constructor set the iterator to the first outgoing edge of @@ -125,29 +125,32 @@ OutEdgeIt(const LedaGraphWrapper & G, Node n) : Edge(G.l_graph->first_adj_edge(n.l_n)) { } }; + /// This iterator goes trought the incoming edges of a certain node. class InEdgeIt : public Edge { public: /// @warning The default constructor sets the iterator /// to an undefined value. - InEdgeIt() {} + InEdgeIt() { } /// Initialize the iterator to be invalid - InEdgeIt(Invalid i) : Edge(i) {} + InEdgeIt(Invalid i) : Edge(i) { } InEdgeIt(const LedaGraphWrapper & G, Node n) : Edge(G.l_graph->first_in_edge(n.l_n)) { } }; // class SymEdgeIt : public Edge {}; + + /// This iterator goes trought the edges of the graph. class EdgeIt : public Edge { public: /// @warning The default constructor sets the iterator /// to an undefined value. - EdgeIt() {} + EdgeIt() { } /// Initialize the iterator to be invalid - EdgeIt(Invalid i) : Edge(i) {} + EdgeIt(Invalid i) : Edge(i) { } EdgeIt(const LedaGraphWrapper & G) : Edge(G.l_graph->first_edge()) { } }; /// First node of the graph. - + /// /// \post \c i and the return value will be the first node. /// NodeIt &first(NodeIt &i) const { i=NodeIt(*this); return i; } @@ -163,7 +166,7 @@ return i; } // SymEdgeIt &first(SymEdgeIt &, Node) const { return i;} - /// The first edge of the Graph. + /// The first edge of the graph. EdgeIt &first(EdgeIt &i) const { i=EdgeIt(*this); return i; } @@ -253,7 +256,7 @@ int nodeNum() const { return l_graph->number_of_nodes(); } int edgeNum() const { return l_graph->number_of_edges(); } - ///Read/write map from the nodes to type \c T. + /// Read/write map from the nodes to type \c T. template class NodeMap { leda_node_map leda_stuff; @@ -273,7 +276,7 @@ //void update(T a) { leda_stuff.init(leda_stuff.get_graph()/**(G.l_graph)*/, a); } //FIXME: Is it necessary }; - ///Read/write map from the edges to type \c T. + /// Read/write map from the edges to type \c T. template class EdgeMap { leda_edge_map leda_stuff; @@ -294,20 +297,21 @@ }; - ///Read/write map from the nodes to type \c T. + /// This class is to wrap existing + /// LEDA node-maps to HUGO ones. template class NodeMapWrapper { - leda_node_map* leda_stuff; + leda_node_array* leda_stuff; public: typedef T ValueType; typedef Node KeyType; - NodeMapWrapper(leda_node_map& _leda_stuff) : + NodeMapWrapper(leda_node_array& _leda_stuff) : leda_stuff(&_leda_stuff) { } //NodeMap(leda_node_map& &G, T t) : leda_stuff(*(G.l_graph), t) {} void set(Node i, T t) { (*leda_stuff)[i.l_n]=t; } - T get(Node i) const { return (*leda_stuff)[i.l_n]; } //FIXME: Is it necessary + //T get(Node i) const { return (*leda_stuff)[i.l_n]; } //FIXME: Is it necessary T &operator[](Node i) { return (*leda_stuff)[i.l_n]; } const T &operator[](Node i) const { return (*leda_stuff)[i.l_n]; } @@ -315,20 +319,21 @@ //void update(T a) { leda_stuff.init(leda_stuff.get_graph()/**(G.l_graph)*/, a); } //FIXME: Is it necessary }; - ///Read/write map from the edges to type \c T. + /// This class is to wrap existing + /// LEDA edge-maps to HUGO ones. template class EdgeMapWrapper { - leda_edge_map* leda_stuff; + leda_edge_array* leda_stuff; public: typedef T ValueType; typedef Edge KeyType; - EdgeMapWrapper(leda_edge_map& _leda_stuff) : + EdgeMapWrapper(leda_edge_array& _leda_stuff) : leda_stuff(_leda_stuff) { } //EdgeMap(const LedaGraphWrapper &G, T t) : leda_stuff(*(G.l_graph), t) {} void set(Edge i, T t) { (*leda_stuff)[i.l_e]=t; } - T get(Edge i) const { return (*leda_stuff)[i.l_e]; } //FIXME: Is it necessary + //T get(Edge i) const { return (*leda_stuff)[i.l_e]; } //FIXME: Is it necessary T &operator[](Edge i) { return (*leda_stuff)[i.l_e]; } const T &operator[](Edge i) const { return (*leda_stuff)[i.l_e]; } @@ -336,6 +341,26 @@ //void update(T a) { leda_stuff.init(leda_stuff.get_graph()/**(G.l_graph)*/, a); } //FIXME: Is it necessary }; + /// This class is used for access node-data of + /// LEDA parametrized graphs. + template + class NodeDataMap : public NodeMapWrapper + { + public: + NodeDataMap(LedaGraphWrapper& LGW) : + NodeMapWrapper(*(LGW._g_graph).node_data()) { } + }; + + /// This class is used for access edge-data of + /// LEDA parametrized graphs. + template + class EdgeDataMap : public EdgeMapWrapper + { + public: + EdgeDataMap(LedaGraphWrapper& LGW) : + EdgeMapWrapper(*(LGW._g_graph).edge_data()) { } + }; + };