77 /// This iterator goes through each node. |
78 /// This iterator goes through each node. |
78 class NodeIt : public Node { |
79 class NodeIt : public Node { |
79 public: |
80 public: |
80 /// @warning The default constructor sets the iterator |
81 /// @warning The default constructor sets the iterator |
81 /// to an undefined value. |
82 /// to an undefined value. |
82 NodeIt() {} //FIXME |
83 NodeIt() { } //FIXME |
83 /// Initialize the iterator to be invalid |
84 /// Initialize the iterator to be invalid |
84 NodeIt(Invalid i) : Node(i) {} |
85 NodeIt(Invalid i) : Node(i) { } |
85 /// Sets the iterator to the first node of \c G. |
86 /// Sets the iterator to the first node of \c G. |
86 NodeIt(const LedaGraphWrapper &G) : Node(G.l_graph->first_node()) { } |
87 NodeIt(const LedaGraphWrapper &G) : Node(G.l_graph->first_node()) { } |
87 //NodeIt(const NodeIt &) {} //FIXME |
88 //NodeIt(const NodeIt &) {} //FIXME |
88 }; |
89 }; |
89 |
90 |
90 /// The base type of the edge iterators. |
91 /// Trivial edge-iterator. |
91 class Edge { |
92 class Edge { |
92 friend class LedaGraphWrapper; |
93 friend class LedaGraphWrapper; |
93 protected: |
94 protected: |
94 template <typename T> friend class EdgeMap; |
95 template <typename T> friend class EdgeMap; |
95 leda_edge l_e; |
96 leda_edge l_e; |
96 public: //FIXME |
97 public: //FIXME |
97 Edge(leda_edge _l_e) : l_e(_l_e) { } |
98 Edge(leda_edge _l_e) : l_e(_l_e) { } |
98 public: |
99 public: |
99 /// @warning The default constructor sets the iterator |
100 /// @warning The default constructor sets the iterator |
100 /// to an undefined value. |
101 /// to an undefined value. |
101 Edge() {} //FIXME |
102 Edge() { } //FIXME |
102 /// Initialize the iterator to be invalid |
103 /// Initialize the iterator to be invalid |
103 Edge(Invalid) : l_e(0) {} |
104 Edge(Invalid) : l_e(0) { } |
104 //Edge(const Edge &) {} |
105 //Edge(const Edge &) {} |
105 bool operator==(Edge e) const { return l_e==e.l_e; } //FIXME |
106 bool operator==(Edge e) const { return l_e==e.l_e; } //FIXME |
106 bool operator!=(Edge e) const { return l_e!=e.l_e; } //FIXME |
107 bool operator!=(Edge e) const { return l_e!=e.l_e; } //FIXME |
107 operator leda_edge () { return l_e; } |
108 operator leda_edge () { return l_e; } |
108 }; |
109 }; |
109 |
110 |
110 /// This iterator goes trought the outgoing edges of a certain graph. |
111 /// This iterator goes trought the outgoing edges of a certain node. |
111 |
|
112 class OutEdgeIt : public Edge { |
112 class OutEdgeIt : public Edge { |
113 public: |
113 public: |
114 /// @warning The default constructor sets the iterator |
114 /// @warning The default constructor sets the iterator |
115 /// to an undefined value. |
115 /// to an undefined value. |
116 OutEdgeIt() {} |
116 OutEdgeIt() { } |
117 /// Initialize the iterator to be invalid |
117 /// Initialize the iterator to be invalid |
118 OutEdgeIt(Invalid i) : Edge(i) {} |
118 OutEdgeIt(Invalid i) : Edge(i) { } |
119 /// This constructor sets the iterator to first outgoing edge. |
119 /// This constructor sets the iterator to first outgoing edge. |
120 |
120 |
121 /// This constructor set the iterator to the first outgoing edge of |
121 /// This constructor set the iterator to the first outgoing edge of |
122 /// node |
122 /// node |
123 ///@param n the node |
123 ///@param n the node |
124 ///@param G the graph |
124 ///@param G the graph |
125 OutEdgeIt(const LedaGraphWrapper & G, Node n) : Edge(G.l_graph->first_adj_edge(n.l_n)) { } |
125 OutEdgeIt(const LedaGraphWrapper & G, Node n) : Edge(G.l_graph->first_adj_edge(n.l_n)) { } |
126 }; |
126 }; |
127 |
127 |
|
128 /// This iterator goes trought the incoming edges of a certain node. |
128 class InEdgeIt : public Edge { |
129 class InEdgeIt : public Edge { |
129 public: |
130 public: |
130 /// @warning The default constructor sets the iterator |
131 /// @warning The default constructor sets the iterator |
131 /// to an undefined value. |
132 /// to an undefined value. |
132 InEdgeIt() {} |
133 InEdgeIt() { } |
133 /// Initialize the iterator to be invalid |
134 /// Initialize the iterator to be invalid |
134 InEdgeIt(Invalid i) : Edge(i) {} |
135 InEdgeIt(Invalid i) : Edge(i) { } |
135 InEdgeIt(const LedaGraphWrapper & G, Node n) : Edge(G.l_graph->first_in_edge(n.l_n)) { } |
136 InEdgeIt(const LedaGraphWrapper & G, Node n) : Edge(G.l_graph->first_in_edge(n.l_n)) { } |
136 }; |
137 }; |
137 |
138 |
138 // class SymEdgeIt : public Edge {}; |
139 // class SymEdgeIt : public Edge {}; |
|
140 |
|
141 /// This iterator goes trought the edges of the graph. |
139 class EdgeIt : public Edge { |
142 class EdgeIt : public Edge { |
140 public: |
143 public: |
141 /// @warning The default constructor sets the iterator |
144 /// @warning The default constructor sets the iterator |
142 /// to an undefined value. |
145 /// to an undefined value. |
143 EdgeIt() {} |
146 EdgeIt() { } |
144 /// Initialize the iterator to be invalid |
147 /// Initialize the iterator to be invalid |
145 EdgeIt(Invalid i) : Edge(i) {} |
148 EdgeIt(Invalid i) : Edge(i) { } |
146 EdgeIt(const LedaGraphWrapper & G) : Edge(G.l_graph->first_edge()) { } |
149 EdgeIt(const LedaGraphWrapper & G) : Edge(G.l_graph->first_edge()) { } |
147 }; |
150 }; |
148 |
151 |
149 /// First node of the graph. |
152 /// First node of the graph. |
150 |
153 /// |
151 /// \post \c i and the return value will be the first node. |
154 /// \post \c i and the return value will be the first node. |
152 /// |
155 /// |
153 NodeIt &first(NodeIt &i) const { i=NodeIt(*this); return i; } |
156 NodeIt &first(NodeIt &i) const { i=NodeIt(*this); return i; } |
154 |
157 |
155 /// The first outgoing edge. |
158 /// The first outgoing edge. |
292 void update() { /*leda_stuff.init(leda_stuff.get_graph());*/ } |
295 void update() { /*leda_stuff.init(leda_stuff.get_graph());*/ } |
293 //void update(T a) { leda_stuff.init(leda_stuff.get_graph()/**(G.l_graph)*/, a); } //FIXME: Is it necessary |
296 //void update(T a) { leda_stuff.init(leda_stuff.get_graph()/**(G.l_graph)*/, a); } //FIXME: Is it necessary |
294 }; |
297 }; |
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 template<typename T> class NodeMapWrapper |
302 template<typename T> class NodeMapWrapper |
299 { |
303 { |
300 leda_node_map<T>* leda_stuff; |
304 leda_node_array<T>* leda_stuff; |
301 public: |
305 public: |
302 typedef T ValueType; |
306 typedef T ValueType; |
303 typedef Node KeyType; |
307 typedef Node KeyType; |
304 |
308 |
305 NodeMapWrapper(leda_node_map<T>& _leda_stuff) : |
309 NodeMapWrapper(leda_node_array<T>& _leda_stuff) : |
306 leda_stuff(&_leda_stuff) { } |
310 leda_stuff(&_leda_stuff) { } |
307 //NodeMap(leda_node_map& &G, T t) : leda_stuff(*(G.l_graph), t) {} |
311 //NodeMap(leda_node_map& &G, T t) : leda_stuff(*(G.l_graph), t) {} |
308 |
312 |
309 void set(Node i, T t) { (*leda_stuff)[i.l_n]=t; } |
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 necessary |
314 //T get(Node i) const { return (*leda_stuff)[i.l_n]; } //FIXME: Is it necessary |
311 T &operator[](Node i) { return (*leda_stuff)[i.l_n]; } |
315 T &operator[](Node i) { return (*leda_stuff)[i.l_n]; } |
312 const T &operator[](Node i) const { return (*leda_stuff)[i.l_n]; } |
316 const T &operator[](Node i) const { return (*leda_stuff)[i.l_n]; } |
313 |
317 |
314 void update() { /*leda_stuff.init(leda_stuff.get_graph());*/ } |
318 void update() { /*leda_stuff.init(leda_stuff.get_graph());*/ } |
315 //void update(T a) { leda_stuff.init(leda_stuff.get_graph()/**(G.l_graph)*/, a); } //FIXME: Is it necessary |
319 //void update(T a) { leda_stuff.init(leda_stuff.get_graph()/**(G.l_graph)*/, a); } //FIXME: Is it necessary |
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 template<typename T> class EdgeMapWrapper |
324 template<typename T> class EdgeMapWrapper |
320 { |
325 { |
321 leda_edge_map<T>* leda_stuff; |
326 leda_edge_array<T>* leda_stuff; |
322 public: |
327 public: |
323 typedef T ValueType; |
328 typedef T ValueType; |
324 typedef Edge KeyType; |
329 typedef Edge KeyType; |
325 |
330 |
326 EdgeMapWrapper(leda_edge_map<T>& _leda_stuff) : |
331 EdgeMapWrapper(leda_edge_array<T>& _leda_stuff) : |
327 leda_stuff(_leda_stuff) { } |
332 leda_stuff(_leda_stuff) { } |
328 //EdgeMap(const LedaGraphWrapper &G, T t) : leda_stuff(*(G.l_graph), t) {} |
333 //EdgeMap(const LedaGraphWrapper &G, T t) : leda_stuff(*(G.l_graph), t) {} |
329 |
334 |
330 void set(Edge i, T t) { (*leda_stuff)[i.l_e]=t; } |
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 necessary |
336 //T get(Edge i) const { return (*leda_stuff)[i.l_e]; } //FIXME: Is it necessary |
332 T &operator[](Edge i) { return (*leda_stuff)[i.l_e]; } |
337 T &operator[](Edge i) { return (*leda_stuff)[i.l_e]; } |
333 const T &operator[](Edge i) const { return (*leda_stuff)[i.l_e]; } |
338 const T &operator[](Edge i) const { return (*leda_stuff)[i.l_e]; } |
334 |
339 |
335 void update() { /*leda_stuff.init(leda_stuff.get_graph());*/ } |
340 void update() { /*leda_stuff.init(leda_stuff.get_graph());*/ } |
336 //void update(T a) { leda_stuff.init(leda_stuff.get_graph()/**(G.l_graph)*/, a); } //FIXME: Is it necessary |
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 |
339 }; |
364 }; |
340 |
365 |
341 |
366 |