Changeset 617:dc17013b0e52 in lemon0.x for src/work/marci/leda/leda_graph_wrapper.h
 Timestamp:
 05/11/04 23:26:29 (17 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@802
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/work/marci/leda/leda_graph_wrapper.h
r616 r617 17 17 #include <hugo/invalid.h> 18 18 19 /// The namespace of HugoLib20 19 namespace hugo { 21 20 22 // @defgroup empty_graph The LedaGraphWrapper class 23 // @{ 24 25 /// A graph wrapperstructure for wrapping LEDA graphs in HUGO. 26 27 /// This graph wrapper class wraps LEDA graph and LEDA parametrized graph 28 /// and then the generic algorithms and wrappers of HUGO can be used 21 /// \brief A graph wrapper structure for wrapping LEDA graphs in HUGO. 22 /// 23 /// This graph wrapper class wraps LEDA graphs and LEDA parametrized graphs 24 /// to satisfy HUGO graph concepts. 25 /// Then the generic HUGOlib algorithms and wrappers can be used 29 26 /// with LEDA graphs. 30 /// This class provides all the common features of a grapf structure, 31 /// however completely without implementations or real data structures 32 /// behind the interface. 33 /// All graph algorithms should compile with this class, but it will not 34 /// run properly, of course. 35 /// 36 /// It can be used for checking the interface compatibility, 37 /// or it can serve as a skeleton of a new graph structure. 38 /// 39 /// Also, you will find here the full documentation of a certain graph 40 /// feature, the documentation of a real graph imlementation 41 /// like @ref ListGraph or 42 /// @ref SmartGraph will just refer to this structure. 27 /// \ingroup gwrapper 43 28 template<typename Graph> 44 29 class LedaGraphWrapper 45 30 { 46 31 protected: 47 Graph* _graph;48 LedaGraphWrapper() : _graph(0) { }49 void setGraph(Graph& _ _graph) { _graph=&__graph; }32 Graph* l_graph; 33 LedaGraphWrapper() : l_graph(0) { } 34 void setGraph(Graph& _l_graph) { l_graph=&_l_graph; } 50 35 public: 51 36 52 37 //LedaGraphWrapper() { } 53 LedaGraphWrapper(Graph& _ _graph) : _graph(&__graph) { }54 LedaGraphWrapper(const LedaGraphWrapper &G) : _graph(G._graph) { }38 LedaGraphWrapper(Graph& _l_graph) : l_graph(&_l_graph) { } 39 LedaGraphWrapper(const LedaGraphWrapper &G) : l_graph(G.l_graph) { } 55 40 56 41 template <typename T> class NodeMap; … … 73 58 protected: 74 59 template <typename T> friend class NodeMap; 75 leda_node _n;60 leda_node l_n; 76 61 public: //FIXME 77 Node(leda_node _ _n) : _n(__n) { }62 Node(leda_node _l_n) : l_n(_l_n) { } 78 63 public: 79 64 /// @warning The default constructor sets the iterator … … 81 66 Node() {} //FIXME 82 67 /// Initialize the iterator to be invalid 83 Node(Invalid) : _n(0) { }68 Node(Invalid) : l_n(0) { } 84 69 //Node(const Node &) {} 85 bool operator==(Node n) const { return _n==n._n; } //FIXME86 bool operator!=(Node n) const { return _n!=n._n; } //FIXME87 operator leda_node () { return _n; }70 bool operator==(Node n) const { return l_n==n.l_n; } //FIXME 71 bool operator!=(Node n) const { return l_n!=n.l_n; } //FIXME 72 operator leda_node () { return l_n; } 88 73 }; 89 74 … … 97 82 NodeIt(Invalid i) : Node(i) {} 98 83 /// Sets the iterator to the first node of \c G. 99 NodeIt(const LedaGraphWrapper &G) : Node(G. _graph>first_node()) { }84 NodeIt(const LedaGraphWrapper &G) : Node(G.l_graph>first_node()) { } 100 85 //NodeIt(const NodeIt &) {} //FIXME 101 86 }; … … 106 91 protected: 107 92 template <typename T> friend class EdgeMap; 108 leda_edge _e;93 leda_edge l_e; 109 94 public: //FIXME 110 Edge(leda_edge _ _e) : _e(__e) { }95 Edge(leda_edge _l_e) : l_e(_l_e) { } 111 96 public: 112 97 /// @warning The default constructor sets the iterator … … 114 99 Edge() {} //FIXME 115 100 /// Initialize the iterator to be invalid 116 Edge(Invalid) : _e(0) {}101 Edge(Invalid) : l_e(0) {} 117 102 //Edge(const Edge &) {} 118 bool operator==(Edge e) const { return _e==e._e; } //FIXME119 bool operator!=(Edge e) const { return _e!=e._e; } //FIXME120 operator leda_edge () { return _e; }103 bool operator==(Edge e) const { return l_e==e.l_e; } //FIXME 104 bool operator!=(Edge e) const { return l_e!=e.l_e; } //FIXME 105 operator leda_edge () { return l_e; } 121 106 }; 122 107 … … 136 121 ///@param n the node 137 122 ///@param G the graph 138 OutEdgeIt(const LedaGraphWrapper & G, Node n) : Edge(G. _graph>first_adj_edge(n._n)) { }123 OutEdgeIt(const LedaGraphWrapper & G, Node n) : Edge(G.l_graph>first_adj_edge(n.l_n)) { } 139 124 }; 140 125 … … 146 131 /// Initialize the iterator to be invalid 147 132 InEdgeIt(Invalid i) : Edge(i) {} 148 InEdgeIt(const LedaGraphWrapper & G, Node n) : Edge(G. _graph>first_in_edge(n._n)) { }133 InEdgeIt(const LedaGraphWrapper & G, Node n) : Edge(G.l_graph>first_in_edge(n.l_n)) { } 149 134 }; 150 135 … … 157 142 /// Initialize the iterator to be invalid 158 143 EdgeIt(Invalid i) : Edge(i) {} 159 EdgeIt(const LedaGraphWrapper & G) : Edge(G. _graph>first_edge()) { }144 EdgeIt(const LedaGraphWrapper & G) : Edge(G.l_graph>first_edge()) { } 160 145 }; 161 146 … … 190 175 /// Go to the next node. 191 176 NodeIt &next(NodeIt &i) const { 192 i. _n=_graph>succ_node(i._n);177 i.l_n=l_graph>succ_node(i.l_n); 193 178 return i; 194 179 } 195 180 /// Go to the next incoming edge. 196 181 InEdgeIt &next(InEdgeIt &i) const { 197 i. _e=_graph>in_succ(i._e);182 i.l_e=l_graph>in_succ(i.l_e); 198 183 return i; 199 184 } 200 185 /// Go to the next outgoing edge. 201 186 OutEdgeIt &next(OutEdgeIt &i) const { 202 i. _e=_graph>adj_succ(i._e);187 i.l_e=l_graph>adj_succ(i.l_e); 203 188 return i; 204 189 } … … 206 191 /// Go to the next edge. 207 192 EdgeIt &next(EdgeIt &i) const { 208 i. _e=_graph>succ_edge(i._e);193 i.l_e=l_graph>succ_edge(i.l_e); 209 194 return i; 210 195 } … … 226 211 ///Gives back the head node of an edge. 227 212 Node head(Edge e) const { 228 return Node( _graph>target(e._e));213 return Node(l_graph>target(e.l_e)); 229 214 } 230 215 ///Gives back the tail node of an edge. 231 216 Node tail(Edge e) const { 232 return Node( _graph>source(e._e));217 return Node(l_graph>source(e.l_e)); 233 218 } 234 219 … … 242 227 243 228 /// Checks if a node iterator is valid 244 bool valid(Node n) const { return n. _n; }229 bool valid(Node n) const { return n.l_n; } 245 230 /// Checks if an edge iterator is valid 246 bool valid(Edge e) const { return e. _e; }231 bool valid(Edge e) const { return e.l_e; } 247 232 248 233 ///Gives back the \e id of a node. 249 int id(Node n) const { return n. _n>id(); }234 int id(Node n) const { return n.l_n>id(); } 250 235 ///Gives back the \e id of an edge. 251 int id(Edge e) const { return e. _e>id(); }236 int id(Edge e) const { return e.l_e>id(); } 252 237 253 238 //void setInvalid(Node &) const {}; 254 239 //void setInvalid(Edge &) const {}; 255 240 256 Node addNode() const { return Node( _graph>new_node()); }241 Node addNode() const { return Node(l_graph>new_node()); } 257 242 Edge addEdge(Node tail, Node head) const { 258 return Edge( _graph>new_edge(tail._n, head._n));259 } 260 261 void erase(Node n) const { _graph>del_node(n._n); }262 void erase(Edge e) const { _graph>del_edge(e._e); }263 264 void clear() const { _graph>clear(); }265 266 int nodeNum() const { return _graph>number_of_nodes(); }267 int edgeNum() const { return _graph>number_of_edges(); }243 return Edge(l_graph>new_edge(tail.l_n, head.l_n)); 244 } 245 246 void erase(Node n) const { l_graph>del_node(n.l_n); } 247 void erase(Edge e) const { l_graph>del_edge(e.l_e); } 248 249 void clear() const { l_graph>clear(); } 250 251 int nodeNum() const { return l_graph>number_of_nodes(); } 252 int edgeNum() const { return l_graph>number_of_edges(); } 268 253 269 254 ///Read/write map from the nodes to type \c T. … … 275 260 typedef Node KeyType; 276 261 277 NodeMap(const LedaGraphWrapper &G) : leda_stuff(*(G. _graph)) {}278 NodeMap(const LedaGraphWrapper &G, T t) : leda_stuff(*(G. _graph), t) {}279 280 void set(Node i, T t) { leda_stuff[i. _n]=t; }281 T get(Node i) const { return leda_stuff[i. _n]; } //FIXME: Is it necessary282 T &operator[](Node i) { return leda_stuff[i. _n]; }283 const T &operator[](Node i) const { return leda_stuff[i. _n]; }262 NodeMap(const LedaGraphWrapper &G) : leda_stuff(*(G.l_graph)) {} 263 NodeMap(const LedaGraphWrapper &G, T t) : leda_stuff(*(G.l_graph), t) {} 264 265 void set(Node i, T t) { leda_stuff[i.l_n]=t; } 266 T get(Node i) const { return leda_stuff[i.l_n]; } //FIXME: Is it necessary 267 T &operator[](Node i) { return leda_stuff[i.l_n]; } 268 const T &operator[](Node i) const { return leda_stuff[i.l_n]; } 284 269 285 270 void update() { /*leda_stuff.init(leda_stuff.get_graph());*/ } 286 //void update(T a) { leda_stuff.init(leda_stuff.get_graph()/**(G. _graph)*/, a); } //FIXME: Is it necessary271 //void update(T a) { leda_stuff.init(leda_stuff.get_graph()/**(G.l_graph)*/, a); } //FIXME: Is it necessary 287 272 }; 288 273 … … 295 280 typedef Edge KeyType; 296 281 297 EdgeMap(const LedaGraphWrapper &G) : leda_stuff(*(G. _graph)) {}298 EdgeMap(const LedaGraphWrapper &G, T t) : leda_stuff(*(G. _graph), t) {}299 300 void set(Edge i, T t) { leda_stuff[i. _e]=t; }301 T get(Edge i) const { return leda_stuff[i. _e]; } //FIXME: Is it necessary302 T &operator[](Edge i) { return leda_stuff[i. _e]; }303 const T &operator[](Edge i) const { return leda_stuff[i. _e]; }282 EdgeMap(const LedaGraphWrapper &G) : leda_stuff(*(G.l_graph)) {} 283 EdgeMap(const LedaGraphWrapper &G, T t) : leda_stuff(*(G.l_graph), t) {} 284 285 void set(Edge i, T t) { leda_stuff[i.l_e]=t; } 286 T get(Edge i) const { return leda_stuff[i.l_e]; } //FIXME: Is it necessary 287 T &operator[](Edge i) { return leda_stuff[i.l_e]; } 288 const T &operator[](Edge i) const { return leda_stuff[i.l_e]; } 304 289 305 290 void update() { /*leda_stuff.init(leda_stuff.get_graph());*/ } 306 //void update(T a) { leda_stuff.init(leda_stuff.get_graph()/**(G. _graph)*/, a); } //FIXME: Is it necessary291 //void update(T a) { leda_stuff.init(leda_stuff.get_graph()/**(G.l_graph)*/, a); } //FIXME: Is it necessary 307 292 }; 308 293 309 294 }; 310 295 296 297 /// \brief LEDA graph template. 298 /// 299 /// This graph stucture uses LEDA graphs for physical storage. 300 /// \ingroup graphs 311 301 template<typename Graph> 312 302 class LedaGraph : public LedaGraphWrapper<Graph> { … … 320 310 }; 321 311 322 // @}323 324 312 } //namespace hugo 325 313 326 327 328 // class EmptyBipGraph : public EmptyGraph329 // {330 // class ANode {};331 // class BNode {};332 333 // ANode &next(ANode &) {}334 // BNode &next(BNode &) {}335 336 // ANode &getFirst(ANode &) const {}337 // BNode &getFirst(BNode &) const {}338 339 // enum NodeClass { A = 0, B = 1 };340 // NodeClass getClass(Node n) {}341 342 // }343 344 314 #endif // HUGO_LEDA_GRAPH_WRAPPER_H
Note: See TracChangeset
for help on using the changeset viewer.