0
5
0
... | ... |
@@ -136,51 +136,50 @@ |
136 | 136 |
void firstIn(Arc& arc, const Node& node) const { |
137 | 137 |
arc._id = _arc_num + node._id - _node_num; |
138 | 138 |
} |
139 | 139 |
|
140 | 140 |
void nextIn(Arc& arc) const { |
141 | 141 |
arc._id -= _node_num; |
142 | 142 |
if (arc._id < 0) arc._id = -1; |
143 | 143 |
} |
144 | 144 |
|
145 | 145 |
}; |
146 | 146 |
|
147 | 147 |
typedef DigraphExtender<FullDigraphBase> ExtendedFullDigraphBase; |
148 | 148 |
|
149 | 149 |
/// \ingroup graphs |
150 | 150 |
/// |
151 | 151 |
/// \brief A full digraph class. |
152 | 152 |
/// |
153 | 153 |
/// This is a simple and fast directed full graph implementation. |
154 | 154 |
/// From each node go arcs to each node (including the source node), |
155 | 155 |
/// therefore the number of the arcs in the digraph is the square of |
156 | 156 |
/// the node number. This digraph type is completely static, so you |
157 | 157 |
/// can neither add nor delete either arcs or nodes, and it needs |
158 | 158 |
/// constant space in memory. |
159 | 159 |
/// |
160 |
/// This class conforms to the \ref concepts::Digraph "Digraph" concept |
|
161 |
/// and it also has an important extra feature that its maps are |
|
162 |
/// |
|
160 |
/// This class fully conforms to the \ref concepts::Digraph |
|
161 |
/// "Digraph concept". |
|
163 | 162 |
/// |
164 | 163 |
/// The \c FullDigraph and \c FullGraph classes are very similar, |
165 | 164 |
/// but there are two differences. While this class conforms only |
166 | 165 |
/// to the \ref concepts::Digraph "Digraph" concept, the \c FullGraph |
167 | 166 |
/// class conforms to the \ref concepts::Graph "Graph" concept, |
168 | 167 |
/// moreover \c FullGraph does not contain a loop arc for each |
169 | 168 |
/// node as \c FullDigraph does. |
170 | 169 |
/// |
171 | 170 |
/// \sa FullGraph |
172 | 171 |
class FullDigraph : public ExtendedFullDigraphBase { |
173 | 172 |
public: |
174 | 173 |
|
175 | 174 |
typedef ExtendedFullDigraphBase Parent; |
176 | 175 |
|
177 | 176 |
/// \brief Constructor |
178 | 177 |
FullDigraph() { construct(0); } |
179 | 178 |
|
180 | 179 |
/// \brief Constructor |
181 | 180 |
/// |
182 | 181 |
/// Constructor. |
183 | 182 |
/// \param n The number of the nodes. |
184 | 183 |
FullDigraph(int n) { construct(n); } |
185 | 184 |
|
186 | 185 |
/// \brief Resizes the digraph |
... | ... |
@@ -506,51 +505,49 @@ |
506 | 505 |
dir = false; |
507 | 506 |
} |
508 | 507 |
} else { |
509 | 508 |
_uvid(edge._id, v, u); |
510 | 509 |
--v; |
511 | 510 |
edge._id = (v != -1 ? _eid(v, u) : -1); |
512 | 511 |
} |
513 | 512 |
} |
514 | 513 |
|
515 | 514 |
}; |
516 | 515 |
|
517 | 516 |
typedef GraphExtender<FullGraphBase> ExtendedFullGraphBase; |
518 | 517 |
|
519 | 518 |
/// \ingroup graphs |
520 | 519 |
/// |
521 | 520 |
/// \brief An undirected full graph class. |
522 | 521 |
/// |
523 | 522 |
/// This is a simple and fast undirected full graph |
524 | 523 |
/// implementation. From each node go edge to each other node, |
525 | 524 |
/// therefore the number of edges in the graph is \f$n(n-1)/2\f$. |
526 | 525 |
/// This graph type is completely static, so you can neither |
527 | 526 |
/// add nor delete either edges or nodes, and it needs constant |
528 | 527 |
/// space in memory. |
529 | 528 |
/// |
530 |
/// This class conforms to the \ref concepts::Graph "Graph" concept |
|
531 |
/// and it also has an important extra feature that its maps are |
|
532 |
/// |
|
529 |
/// This class fully conforms to the \ref concepts::Graph "Graph concept". |
|
533 | 530 |
/// |
534 | 531 |
/// The \c FullGraph and \c FullDigraph classes are very similar, |
535 | 532 |
/// but there are two differences. While the \c FullDigraph class |
536 | 533 |
/// conforms only to the \ref concepts::Digraph "Digraph" concept, |
537 | 534 |
/// this class conforms to the \ref concepts::Graph "Graph" concept, |
538 | 535 |
/// moreover \c FullGraph does not contain a loop arc for each |
539 | 536 |
/// node as \c FullDigraph does. |
540 | 537 |
/// |
541 | 538 |
/// \sa FullDigraph |
542 | 539 |
class FullGraph : public ExtendedFullGraphBase { |
543 | 540 |
public: |
544 | 541 |
|
545 | 542 |
typedef ExtendedFullGraphBase Parent; |
546 | 543 |
|
547 | 544 |
/// \brief Constructor |
548 | 545 |
FullGraph() { construct(0); } |
549 | 546 |
|
550 | 547 |
/// \brief Constructor |
551 | 548 |
/// |
552 | 549 |
/// Constructor. |
553 | 550 |
/// \param n The number of the nodes. |
554 | 551 |
FullGraph(int n) { construct(n); } |
555 | 552 |
|
556 | 553 |
/// \brief Resizes the graph |
... | ... |
@@ -476,51 +476,49 @@ |
476 | 476 |
/// [0..height()-1] range. Two nodes are connected in the graph if |
477 | 477 |
/// the indexes differ exactly on one position and exactly one is |
478 | 478 |
/// the difference. The nodes of the graph can be indexed by position |
479 | 479 |
/// with the \c operator()() function. The positions of the nodes can be |
480 | 480 |
/// get with \c pos(), \c col() and \c row() members. The outgoing |
481 | 481 |
/// arcs can be retrieved with the \c right(), \c up(), \c left() |
482 | 482 |
/// and \c down() functions, where the bottom-left corner is the |
483 | 483 |
/// origin. |
484 | 484 |
/// |
485 | 485 |
/// \image html grid_graph.png |
486 | 486 |
/// \image latex grid_graph.eps "Grid graph" width=\textwidth |
487 | 487 |
/// |
488 | 488 |
/// A short example about the basic usage: |
489 | 489 |
///\code |
490 | 490 |
/// GridGraph graph(rows, cols); |
491 | 491 |
/// GridGraph::NodeMap<int> val(graph); |
492 | 492 |
/// for (int i = 0; i < graph.width(); ++i) { |
493 | 493 |
/// for (int j = 0; j < graph.height(); ++j) { |
494 | 494 |
/// val[graph(i, j)] = i + j; |
495 | 495 |
/// } |
496 | 496 |
/// } |
497 | 497 |
///\endcode |
498 | 498 |
/// |
499 | 499 |
/// This graph type fully conforms to the \ref concepts::Graph |
500 |
/// "Graph" concept, and it also has an important extra feature |
|
501 |
/// that its maps are real \ref concepts::ReferenceMap |
|
502 |
/// " |
|
500 |
/// "Graph concept". |
|
503 | 501 |
class GridGraph : public ExtendedGridGraphBase { |
504 | 502 |
public: |
505 | 503 |
|
506 | 504 |
typedef ExtendedGridGraphBase Parent; |
507 | 505 |
|
508 | 506 |
/// \brief Map to get the indices of the nodes as dim2::Point<int>. |
509 | 507 |
/// |
510 | 508 |
/// Map to get the indices of the nodes as dim2::Point<int>. |
511 | 509 |
class IndexMap { |
512 | 510 |
public: |
513 | 511 |
/// \brief The key type of the map |
514 | 512 |
typedef GridGraph::Node Key; |
515 | 513 |
/// \brief The value type of the map |
516 | 514 |
typedef dim2::Point<int> Value; |
517 | 515 |
|
518 | 516 |
/// \brief Constructor |
519 | 517 |
/// |
520 | 518 |
/// Constructor |
521 | 519 |
IndexMap(const GridGraph& graph) : _graph(graph) {} |
522 | 520 |
|
523 | 521 |
/// \brief The subscript operator |
524 | 522 |
/// |
525 | 523 |
/// The subscript operator. |
526 | 524 |
Value operator[](Key key) const { |
... | ... |
@@ -271,51 +271,49 @@ |
271 | 271 |
} |
272 | 272 |
|
273 | 273 |
private: |
274 | 274 |
int _dim; |
275 | 275 |
int _node_num, _edge_num; |
276 | 276 |
}; |
277 | 277 |
|
278 | 278 |
|
279 | 279 |
typedef GraphExtender<HypercubeGraphBase> ExtendedHypercubeGraphBase; |
280 | 280 |
|
281 | 281 |
/// \ingroup graphs |
282 | 282 |
/// |
283 | 283 |
/// \brief Hypercube graph class |
284 | 284 |
/// |
285 | 285 |
/// This class implements a special graph type. The nodes of the graph |
286 | 286 |
/// are indiced with integers with at most \c dim binary digits. |
287 | 287 |
/// Two nodes are connected in the graph if and only if their indices |
288 | 288 |
/// differ only on one position in the binary form. |
289 | 289 |
/// |
290 | 290 |
/// \note The type of the indices is chosen to \c int for efficiency |
291 | 291 |
/// reasons. Thus the maximum dimension of this implementation is 26 |
292 | 292 |
/// (assuming that the size of \c int is 32 bit). |
293 | 293 |
/// |
294 | 294 |
/// This graph type fully conforms to the \ref concepts::Graph |
295 |
/// "Graph" concept, and it also has an important extra feature |
|
296 |
/// that its maps are real \ref concepts::ReferenceMap |
|
297 |
/// " |
|
295 |
/// "Graph concept". |
|
298 | 296 |
class HypercubeGraph : public ExtendedHypercubeGraphBase { |
299 | 297 |
public: |
300 | 298 |
|
301 | 299 |
typedef ExtendedHypercubeGraphBase Parent; |
302 | 300 |
|
303 | 301 |
/// \brief Constructs a hypercube graph with \c dim dimensions. |
304 | 302 |
/// |
305 | 303 |
/// Constructs a hypercube graph with \c dim dimensions. |
306 | 304 |
HypercubeGraph(int dim) { construct(dim); } |
307 | 305 |
|
308 | 306 |
/// \brief The number of dimensions. |
309 | 307 |
/// |
310 | 308 |
/// Gives back the number of dimensions. |
311 | 309 |
int dimension() const { |
312 | 310 |
return Parent::dimension(); |
313 | 311 |
} |
314 | 312 |
|
315 | 313 |
/// \brief Returns \c true if the n'th bit of the node is one. |
316 | 314 |
/// |
317 | 315 |
/// Returns \c true if the n'th bit of the node is one. |
318 | 316 |
bool projection(Node node, int n) const { |
319 | 317 |
return Parent::projection(node, n); |
320 | 318 |
} |
321 | 319 |
... | ... |
@@ -299,51 +299,48 @@ |
299 | 299 |
arcs[e.id].source = n.id; |
300 | 300 |
arcs[e.id].prev_out = -1; |
301 | 301 |
arcs[e.id].next_out = nodes[n.id].first_out; |
302 | 302 |
nodes[n.id].first_out = e.id; |
303 | 303 |
} |
304 | 304 |
|
305 | 305 |
}; |
306 | 306 |
|
307 | 307 |
typedef DigraphExtender<ListDigraphBase> ExtendedListDigraphBase; |
308 | 308 |
|
309 | 309 |
/// \addtogroup graphs |
310 | 310 |
/// @{ |
311 | 311 |
|
312 | 312 |
///A general directed graph structure. |
313 | 313 |
|
314 | 314 |
///\ref ListDigraph is a simple and fast <em>directed graph</em> |
315 | 315 |
///implementation based on static linked lists that are stored in |
316 | 316 |
///\c std::vector structures. |
317 | 317 |
/// |
318 | 318 |
///It conforms to the \ref concepts::Digraph "Digraph concept" and it |
319 | 319 |
///also provides several useful additional functionalities. |
320 | 320 |
///Most of the member functions and nested classes are documented |
321 | 321 |
///only in the concept class. |
322 | 322 |
/// |
323 |
///An important extra feature of this digraph implementation is that |
|
324 |
///its maps are real \ref concepts::ReferenceMap "reference map"s. |
|
325 |
/// |
|
326 | 323 |
///\sa concepts::Digraph |
327 | 324 |
|
328 | 325 |
class ListDigraph : public ExtendedListDigraphBase { |
329 | 326 |
private: |
330 | 327 |
///ListDigraph is \e not copy constructible. Use copyDigraph() instead. |
331 | 328 |
|
332 | 329 |
///ListDigraph is \e not copy constructible. Use copyDigraph() instead. |
333 | 330 |
/// |
334 | 331 |
ListDigraph(const ListDigraph &) :ExtendedListDigraphBase() {}; |
335 | 332 |
///\brief Assignment of ListDigraph to another one is \e not allowed. |
336 | 333 |
///Use copyDigraph() instead. |
337 | 334 |
|
338 | 335 |
///Assignment of ListDigraph to another one is \e not allowed. |
339 | 336 |
///Use copyDigraph() instead. |
340 | 337 |
void operator=(const ListDigraph &) {} |
341 | 338 |
public: |
342 | 339 |
|
343 | 340 |
typedef ExtendedListDigraphBase Parent; |
344 | 341 |
|
345 | 342 |
/// Constructor |
346 | 343 |
|
347 | 344 |
/// Constructor. |
348 | 345 |
/// |
349 | 346 |
ListDigraph() {} |
... | ... |
@@ -1155,51 +1152,48 @@ |
1155 | 1152 |
arcs[(2 * e.id) | 1].prev_out = -1; |
1156 | 1153 |
arcs[(2 * e.id) | 1].next_out = nodes[n.id].first_out; |
1157 | 1154 |
nodes[n.id].first_out = ((2 * e.id) | 1); |
1158 | 1155 |
} |
1159 | 1156 |
|
1160 | 1157 |
}; |
1161 | 1158 |
|
1162 | 1159 |
typedef GraphExtender<ListGraphBase> ExtendedListGraphBase; |
1163 | 1160 |
|
1164 | 1161 |
|
1165 | 1162 |
/// \addtogroup graphs |
1166 | 1163 |
/// @{ |
1167 | 1164 |
|
1168 | 1165 |
///A general undirected graph structure. |
1169 | 1166 |
|
1170 | 1167 |
///\ref ListGraph is a simple and fast <em>undirected graph</em> |
1171 | 1168 |
///implementation based on static linked lists that are stored in |
1172 | 1169 |
///\c std::vector structures. |
1173 | 1170 |
/// |
1174 | 1171 |
///It conforms to the \ref concepts::Graph "Graph concept" and it |
1175 | 1172 |
///also provides several useful additional functionalities. |
1176 | 1173 |
///Most of the member functions and nested classes are documented |
1177 | 1174 |
///only in the concept class. |
1178 | 1175 |
/// |
1179 |
///An important extra feature of this graph implementation is that |
|
1180 |
///its maps are real \ref concepts::ReferenceMap "reference map"s. |
|
1181 |
/// |
|
1182 | 1176 |
///\sa concepts::Graph |
1183 | 1177 |
|
1184 | 1178 |
class ListGraph : public ExtendedListGraphBase { |
1185 | 1179 |
private: |
1186 | 1180 |
///ListGraph is \e not copy constructible. Use copyGraph() instead. |
1187 | 1181 |
|
1188 | 1182 |
///ListGraph is \e not copy constructible. Use copyGraph() instead. |
1189 | 1183 |
/// |
1190 | 1184 |
ListGraph(const ListGraph &) :ExtendedListGraphBase() {}; |
1191 | 1185 |
///\brief Assignment of ListGraph to another one is \e not allowed. |
1192 | 1186 |
///Use copyGraph() instead. |
1193 | 1187 |
|
1194 | 1188 |
///Assignment of ListGraph to another one is \e not allowed. |
1195 | 1189 |
///Use copyGraph() instead. |
1196 | 1190 |
void operator=(const ListGraph &) {} |
1197 | 1191 |
public: |
1198 | 1192 |
/// Constructor |
1199 | 1193 |
|
1200 | 1194 |
/// Constructor. |
1201 | 1195 |
/// |
1202 | 1196 |
ListGraph() {} |
1203 | 1197 |
|
1204 | 1198 |
typedef ExtendedListGraphBase Parent; |
1205 | 1199 |
... | ... |
@@ -170,51 +170,49 @@ |
170 | 170 |
void nextOut(Arc& arc) const { |
171 | 171 |
arc._id = arcs[arc._id].next_out; |
172 | 172 |
} |
173 | 173 |
|
174 | 174 |
void firstIn(Arc& arc, const Node& node) const { |
175 | 175 |
arc._id = nodes[node._id].first_in; |
176 | 176 |
} |
177 | 177 |
|
178 | 178 |
void nextIn(Arc& arc) const { |
179 | 179 |
arc._id = arcs[arc._id].next_in; |
180 | 180 |
} |
181 | 181 |
|
182 | 182 |
}; |
183 | 183 |
|
184 | 184 |
typedef DigraphExtender<SmartDigraphBase> ExtendedSmartDigraphBase; |
185 | 185 |
|
186 | 186 |
///\ingroup graphs |
187 | 187 |
/// |
188 | 188 |
///\brief A smart directed graph class. |
189 | 189 |
/// |
190 | 190 |
///This is a simple and fast digraph implementation. |
191 | 191 |
///It is also quite memory efficient, but at the price |
192 | 192 |
///that <b> it does support only limited (only stack-like) |
193 | 193 |
///node and arc deletions</b>. |
194 |
///It conforms to the \ref concepts::Digraph "Digraph concept" with |
|
195 |
///an important extra feature that its maps are real \ref |
|
196 |
///concepts:: |
|
194 |
///It fully conforms to the \ref concepts::Digraph "Digraph concept". |
|
197 | 195 |
/// |
198 | 196 |
///\sa concepts::Digraph. |
199 | 197 |
class SmartDigraph : public ExtendedSmartDigraphBase { |
200 | 198 |
public: |
201 | 199 |
|
202 | 200 |
typedef ExtendedSmartDigraphBase Parent; |
203 | 201 |
|
204 | 202 |
private: |
205 | 203 |
|
206 | 204 |
///SmartDigraph is \e not copy constructible. Use DigraphCopy() instead. |
207 | 205 |
|
208 | 206 |
///SmartDigraph is \e not copy constructible. Use DigraphCopy() instead. |
209 | 207 |
/// |
210 | 208 |
SmartDigraph(const SmartDigraph &) : ExtendedSmartDigraphBase() {}; |
211 | 209 |
///\brief Assignment of SmartDigraph to another one is \e not allowed. |
212 | 210 |
///Use DigraphCopy() instead. |
213 | 211 |
|
214 | 212 |
///Assignment of SmartDigraph to another one is \e not allowed. |
215 | 213 |
///Use DigraphCopy() instead. |
216 | 214 |
void operator=(const SmartDigraph &) {} |
217 | 215 |
|
218 | 216 |
public: |
219 | 217 |
|
220 | 218 |
/// Constructor |
... | ... |
@@ -608,57 +606,51 @@ |
608 | 606 |
|
609 | 607 |
arcs[n | 1].next_out = nodes[u._id].first_out; |
610 | 608 |
nodes[u._id].first_out = (n | 1); |
611 | 609 |
|
612 | 610 |
return Edge(n / 2); |
613 | 611 |
} |
614 | 612 |
|
615 | 613 |
void clear() { |
616 | 614 |
arcs.clear(); |
617 | 615 |
nodes.clear(); |
618 | 616 |
} |
619 | 617 |
|
620 | 618 |
}; |
621 | 619 |
|
622 | 620 |
typedef GraphExtender<SmartGraphBase> ExtendedSmartGraphBase; |
623 | 621 |
|
624 | 622 |
/// \ingroup graphs |
625 | 623 |
/// |
626 | 624 |
/// \brief A smart undirected graph class. |
627 | 625 |
/// |
628 | 626 |
/// This is a simple and fast graph implementation. |
629 | 627 |
/// It is also quite memory efficient, but at the price |
630 | 628 |
/// that <b> it does support only limited (only stack-like) |
631 | 629 |
/// node and arc deletions</b>. |
632 |
/// Except from this it conforms to |
|
633 |
/// the \ref concepts::Graph "Graph concept". |
|
634 |
/// |
|
635 |
/// It also has an |
|
636 |
/// important extra feature that |
|
637 |
/// its maps are real \ref concepts::ReferenceMap "reference map"s. |
|
630 |
/// It fully conforms to the \ref concepts::Graph "Graph concept". |
|
638 | 631 |
/// |
639 | 632 |
/// \sa concepts::Graph. |
640 |
/// |
|
641 | 633 |
class SmartGraph : public ExtendedSmartGraphBase { |
642 | 634 |
private: |
643 | 635 |
|
644 | 636 |
///SmartGraph is \e not copy constructible. Use GraphCopy() instead. |
645 | 637 |
|
646 | 638 |
///SmartGraph is \e not copy constructible. Use GraphCopy() instead. |
647 | 639 |
/// |
648 | 640 |
SmartGraph(const SmartGraph &) : ExtendedSmartGraphBase() {}; |
649 | 641 |
|
650 | 642 |
///\brief Assignment of SmartGraph to another one is \e not allowed. |
651 | 643 |
///Use GraphCopy() instead. |
652 | 644 |
|
653 | 645 |
///Assignment of SmartGraph to another one is \e not allowed. |
654 | 646 |
///Use GraphCopy() instead. |
655 | 647 |
void operator=(const SmartGraph &) {} |
656 | 648 |
|
657 | 649 |
public: |
658 | 650 |
|
659 | 651 |
typedef ExtendedSmartGraphBase Parent; |
660 | 652 |
|
661 | 653 |
/// Constructor |
662 | 654 |
|
663 | 655 |
/// Constructor. |
664 | 656 |
/// |
0 comments (0 inline)