Changeset 650:588ff2ca55bd in lemon-0.x for src/work/marci/leda
- Timestamp:
- 05/20/04 17:40:59 (21 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@850
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/work/marci/leda/leda_graph_wrapper.h
r646 r650 34 34 void setGraph(Graph& _l_graph) { l_graph=&_l_graph; } 35 35 public: 36 37 //LedaGraphWrapper() { }36 37 /// Constructor for wrapping LEDA graphs. 38 38 LedaGraphWrapper(Graph& _l_graph) : l_graph(&_l_graph) { } 39 LedaGraphWrapper(const LedaGraphWrapper &G) : l_graph(G.l_graph) { } 39 /// Copy constructor 40 LedaGraphWrapper(const LedaGraphWrapper &g) : l_graph(g.l_graph) { } 40 41 41 42 template <typename T> class NodeMap; … … 51 52 class InEdgeIt; 52 53 53 /// T he base type of the node iterators.54 /// Trivial node-iterator 54 55 class Node { 55 56 friend class LedaGraphWrapper<Graph>; … … 66 67 /// @warning The default constructor sets the iterator 67 68 /// to an undefined value. 68 Node() { } //FIXME69 Node() { } //FIXME 69 70 /// Initialize the iterator to be invalid 70 71 Node(Invalid) : l_n(0) { } … … 80 81 /// @warning The default constructor sets the iterator 81 82 /// to an undefined value. 82 NodeIt() { } //FIXME83 /// Initialize the iterator to be invalid 84 NodeIt(Invalid i) : Node(i) { }83 NodeIt() { } //FIXME 84 /// Initialize the iterator to be invalid 85 NodeIt(Invalid i) : Node(i) { } 85 86 /// Sets the iterator to the first node of \c G. 86 87 NodeIt(const LedaGraphWrapper &G) : Node(G.l_graph->first_node()) { } … … 88 89 }; 89 90 90 /// T he base type of the edge iterators.91 /// Trivial edge-iterator. 91 92 class Edge { 92 93 friend class LedaGraphWrapper; … … 99 100 /// @warning The default constructor sets the iterator 100 101 /// to an undefined value. 101 Edge() { } //FIXME102 /// Initialize the iterator to be invalid 103 Edge(Invalid) : l_e(0) { }102 Edge() { } //FIXME 103 /// Initialize the iterator to be invalid 104 Edge(Invalid) : l_e(0) { } 104 105 //Edge(const Edge &) {} 105 106 bool operator==(Edge e) const { return l_e==e.l_e; } //FIXME … … 108 109 }; 109 110 110 /// This iterator goes trought the outgoing edges of a certain graph. 111 111 /// This iterator goes trought the outgoing edges of a certain node. 112 112 class OutEdgeIt : public Edge { 113 113 public: 114 114 /// @warning The default constructor sets the iterator 115 115 /// to an undefined value. 116 OutEdgeIt() { }117 /// Initialize the iterator to be invalid 118 OutEdgeIt(Invalid i) : Edge(i) { }116 OutEdgeIt() { } 117 /// Initialize the iterator to be invalid 118 OutEdgeIt(Invalid i) : Edge(i) { } 119 119 /// This constructor sets the iterator to first outgoing edge. 120 120 … … 126 126 }; 127 127 128 /// This iterator goes trought the incoming edges of a certain node. 128 129 class InEdgeIt : public Edge { 129 130 public: 130 131 /// @warning The default constructor sets the iterator 131 132 /// to an undefined value. 132 InEdgeIt() { }133 /// Initialize the iterator to be invalid 134 InEdgeIt(Invalid i) : Edge(i) { }133 InEdgeIt() { } 134 /// Initialize the iterator to be invalid 135 InEdgeIt(Invalid i) : Edge(i) { } 135 136 InEdgeIt(const LedaGraphWrapper & G, Node n) : Edge(G.l_graph->first_in_edge(n.l_n)) { } 136 137 }; 137 138 138 139 // class SymEdgeIt : public Edge {}; 140 141 /// This iterator goes trought the edges of the graph. 139 142 class EdgeIt : public Edge { 140 143 public: 141 144 /// @warning The default constructor sets the iterator 142 145 /// to an undefined value. 143 EdgeIt() { }144 /// Initialize the iterator to be invalid 145 EdgeIt(Invalid i) : Edge(i) { }146 EdgeIt() { } 147 /// Initialize the iterator to be invalid 148 EdgeIt(Invalid i) : Edge(i) { } 146 149 EdgeIt(const LedaGraphWrapper & G) : Edge(G.l_graph->first_edge()) { } 147 150 }; 148 151 149 152 /// First node of the graph. 150 153 /// 151 154 /// \post \c i and the return value will be the first node. 152 155 /// … … 164 167 } 165 168 // SymEdgeIt &first(SymEdgeIt &, Node) const { return i;} 166 /// The first edge of the Graph.169 /// The first edge of the graph. 167 170 EdgeIt &first(EdgeIt &i) const { 168 171 i=EdgeIt(*this); … … 254 257 int edgeNum() const { return l_graph->number_of_edges(); } 255 258 256 /// Read/write map from the nodes to type \c T.259 /// Read/write map from the nodes to type \c T. 257 260 template<typename T> class NodeMap 258 261 { … … 274 277 }; 275 278 276 /// Read/write map from the edges to type \c T.279 /// Read/write map from the edges to type \c T. 277 280 template<typename T> class EdgeMap 278 281 { … … 295 298 296 299 297 ///Read/write map from the nodes to type \c T. 300 /// This class is to wrap existing 301 /// LEDA node-maps to HUGO ones. 298 302 template<typename T> class NodeMapWrapper 299 303 { 300 leda_node_ map<T>* leda_stuff;304 leda_node_array<T>* leda_stuff; 301 305 public: 302 306 typedef T ValueType; 303 307 typedef Node KeyType; 304 308 305 NodeMapWrapper(leda_node_ map<T>& _leda_stuff) :309 NodeMapWrapper(leda_node_array<T>& _leda_stuff) : 306 310 leda_stuff(&_leda_stuff) { } 307 311 //NodeMap(leda_node_map& &G, T t) : leda_stuff(*(G.l_graph), t) {} 308 312 309 313 void set(Node i, T t) { (*leda_stuff)[i.l_n]=t; } 310 T get(Node i) const { return (*leda_stuff)[i.l_n]; } //FIXME: Is it necessary314 //T get(Node i) const { return (*leda_stuff)[i.l_n]; } //FIXME: Is it necessary 311 315 T &operator[](Node i) { return (*leda_stuff)[i.l_n]; } 312 316 const T &operator[](Node i) const { return (*leda_stuff)[i.l_n]; } … … 316 320 }; 317 321 318 ///Read/write map from the edges to type \c T. 322 /// This class is to wrap existing 323 /// LEDA edge-maps to HUGO ones. 319 324 template<typename T> class EdgeMapWrapper 320 325 { 321 leda_edge_ map<T>* leda_stuff;326 leda_edge_array<T>* leda_stuff; 322 327 public: 323 328 typedef T ValueType; 324 329 typedef Edge KeyType; 325 330 326 EdgeMapWrapper(leda_edge_ map<T>& _leda_stuff) :331 EdgeMapWrapper(leda_edge_array<T>& _leda_stuff) : 327 332 leda_stuff(_leda_stuff) { } 328 333 //EdgeMap(const LedaGraphWrapper &G, T t) : leda_stuff(*(G.l_graph), t) {} 329 334 330 335 void set(Edge i, T t) { (*leda_stuff)[i.l_e]=t; } 331 T get(Edge i) const { return (*leda_stuff)[i.l_e]; } //FIXME: Is it necessary336 //T get(Edge i) const { return (*leda_stuff)[i.l_e]; } //FIXME: Is it necessary 332 337 T &operator[](Edge i) { return (*leda_stuff)[i.l_e]; } 333 338 const T &operator[](Edge i) const { return (*leda_stuff)[i.l_e]; } … … 335 340 void update() { /*leda_stuff.init(leda_stuff.get_graph());*/ } 336 341 //void update(T a) { leda_stuff.init(leda_stuff.get_graph()/**(G.l_graph)*/, a); } //FIXME: Is it necessary 342 }; 343 344 /// This class is used for access node-data of 345 /// LEDA parametrized graphs. 346 template<typename T> 347 class NodeDataMap : public NodeMapWrapper<T> 348 { 349 public: 350 NodeDataMap(LedaGraphWrapper<Graph>& LGW) : 351 NodeMapWrapper<T>(*(LGW._g_graph).node_data()) { } 352 }; 353 354 /// This class is used for access edge-data of 355 /// LEDA parametrized graphs. 356 template<typename T> 357 class EdgeDataMap : public EdgeMapWrapper<T> 358 { 359 public: 360 EdgeDataMap(LedaGraphWrapper<Graph>& LGW) : 361 EdgeMapWrapper<T>(*(LGW._g_graph).edge_data()) { } 337 362 }; 338 363
Note: See TracChangeset
for help on using the changeset viewer.