| ... | ... |
@@ -217,231 +217,233 @@ |
| 217 | 217 |
|
| 218 | 218 |
/// This iterator goes through each edge of a graph. |
| 219 | 219 |
/// Its usage is quite simple, for example you can count the number |
| 220 | 220 |
/// of edges in a graph \c g of type \c Graph as follows: |
| 221 | 221 |
///\code |
| 222 | 222 |
/// int count=0; |
| 223 | 223 |
/// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count; |
| 224 | 224 |
///\endcode |
| 225 | 225 |
class EdgeIt : public Edge {
|
| 226 | 226 |
public: |
| 227 | 227 |
/// Default constructor |
| 228 | 228 |
|
| 229 | 229 |
/// @warning The default constructor sets the iterator |
| 230 | 230 |
/// to an undefined value. |
| 231 | 231 |
EdgeIt() { }
|
| 232 | 232 |
/// Copy constructor. |
| 233 | 233 |
|
| 234 | 234 |
/// Copy constructor. |
| 235 | 235 |
/// |
| 236 | 236 |
EdgeIt(const EdgeIt& e) : Edge(e) { }
|
| 237 | 237 |
/// Initialize the iterator to be invalid. |
| 238 | 238 |
|
| 239 | 239 |
/// Initialize the iterator to be invalid. |
| 240 | 240 |
/// |
| 241 | 241 |
EdgeIt(Invalid) { }
|
| 242 | 242 |
/// This constructor sets the iterator to the first edge. |
| 243 | 243 |
|
| 244 | 244 |
/// This constructor sets the iterator to the first edge. |
| 245 | 245 |
EdgeIt(const Graph&) { }
|
| 246 | 246 |
/// Edge -> EdgeIt conversion |
| 247 | 247 |
|
| 248 | 248 |
/// Sets the iterator to the value of the trivial iterator. |
| 249 | 249 |
/// This feature necessitates that each time we |
| 250 | 250 |
/// iterate the edge-set, the iteration order is the |
| 251 | 251 |
/// same. |
| 252 | 252 |
EdgeIt(const Graph&, const Edge&) { }
|
| 253 | 253 |
/// Next edge |
| 254 | 254 |
|
| 255 | 255 |
/// Assign the iterator to the next edge. |
| 256 | 256 |
EdgeIt& operator++() { return *this; }
|
| 257 | 257 |
}; |
| 258 | 258 |
|
| 259 | 259 |
/// \brief This iterator goes trough the incident undirected |
| 260 | 260 |
/// arcs of a node. |
| 261 | 261 |
/// |
| 262 | 262 |
/// This iterator goes trough the incident edges |
| 263 | 263 |
/// of a certain node of a graph. You should assume that the |
| 264 | 264 |
/// loop arcs will be iterated twice. |
| 265 | 265 |
/// |
| 266 | 266 |
/// Its usage is quite simple, for example you can compute the |
| 267 | 267 |
/// degree (i.e. count the number of incident arcs of a node \c n |
| 268 | 268 |
/// in graph \c g of type \c Graph as follows. |
| 269 | 269 |
/// |
| 270 | 270 |
///\code |
| 271 | 271 |
/// int count=0; |
| 272 | 272 |
/// for(Graph::IncEdgeIt e(g, n); e!=INVALID; ++e) ++count; |
| 273 | 273 |
///\endcode |
| 274 | 274 |
class IncEdgeIt : public Edge {
|
| 275 | 275 |
public: |
| 276 | 276 |
/// Default constructor |
| 277 | 277 |
|
| 278 | 278 |
/// @warning The default constructor sets the iterator |
| 279 | 279 |
/// to an undefined value. |
| 280 | 280 |
IncEdgeIt() { }
|
| 281 | 281 |
/// Copy constructor. |
| 282 | 282 |
|
| 283 | 283 |
/// Copy constructor. |
| 284 | 284 |
/// |
| 285 | 285 |
IncEdgeIt(const IncEdgeIt& e) : Edge(e) { }
|
| 286 | 286 |
/// Initialize the iterator to be invalid. |
| 287 | 287 |
|
| 288 | 288 |
/// Initialize the iterator to be invalid. |
| 289 | 289 |
/// |
| 290 | 290 |
IncEdgeIt(Invalid) { }
|
| 291 | 291 |
/// This constructor sets the iterator to first incident arc. |
| 292 | 292 |
|
| 293 | 293 |
/// This constructor set the iterator to the first incident arc of |
| 294 | 294 |
/// the node. |
| 295 | 295 |
IncEdgeIt(const Graph&, const Node&) { }
|
| 296 | 296 |
/// Edge -> IncEdgeIt conversion |
| 297 | 297 |
|
| 298 | 298 |
/// Sets the iterator to the value of the trivial iterator \c e. |
| 299 | 299 |
/// This feature necessitates that each time we |
| 300 | 300 |
/// iterate the arc-set, the iteration order is the same. |
| 301 | 301 |
IncEdgeIt(const Graph&, const Edge&) { }
|
| 302 | 302 |
/// Next incident arc |
| 303 | 303 |
|
| 304 | 304 |
/// Assign the iterator to the next incident arc |
| 305 | 305 |
/// of the corresponding node. |
| 306 | 306 |
IncEdgeIt& operator++() { return *this; }
|
| 307 | 307 |
}; |
| 308 | 308 |
|
| 309 | 309 |
/// The directed arc type. |
| 310 | 310 |
|
| 311 | 311 |
/// The directed arc type. It can be converted to the |
| 312 | 312 |
/// edge or it should be inherited from the undirected |
| 313 |
/// arc. |
|
| 314 |
class Arc : public Edge {
|
|
| 313 |
/// edge. |
|
| 314 |
class Arc {
|
|
| 315 | 315 |
public: |
| 316 | 316 |
/// Default constructor |
| 317 | 317 |
|
| 318 | 318 |
/// @warning The default constructor sets the iterator |
| 319 | 319 |
/// to an undefined value. |
| 320 | 320 |
Arc() { }
|
| 321 | 321 |
/// Copy constructor. |
| 322 | 322 |
|
| 323 | 323 |
/// Copy constructor. |
| 324 | 324 |
/// |
| 325 |
Arc(const Arc& |
|
| 325 |
Arc(const Arc&) { }
|
|
| 326 | 326 |
/// Initialize the iterator to be invalid. |
| 327 | 327 |
|
| 328 | 328 |
/// Initialize the iterator to be invalid. |
| 329 | 329 |
/// |
| 330 | 330 |
Arc(Invalid) { }
|
| 331 | 331 |
/// Equality operator |
| 332 | 332 |
|
| 333 | 333 |
/// Two iterators are equal if and only if they point to the |
| 334 | 334 |
/// same object or both are invalid. |
| 335 | 335 |
bool operator==(Arc) const { return true; }
|
| 336 | 336 |
/// Inequality operator |
| 337 | 337 |
|
| 338 | 338 |
/// \sa operator==(Arc n) |
| 339 | 339 |
/// |
| 340 | 340 |
bool operator!=(Arc) const { return true; }
|
| 341 | 341 |
|
| 342 | 342 |
/// Artificial ordering operator. |
| 343 | 343 |
|
| 344 | 344 |
/// To allow the use of graph descriptors as key type in std::map or |
| 345 | 345 |
/// similar associative container we require this. |
| 346 | 346 |
/// |
| 347 | 347 |
/// \note This operator only have to define some strict ordering of |
| 348 | 348 |
/// the items; this order has nothing to do with the iteration |
| 349 | 349 |
/// ordering of the items. |
| 350 | 350 |
bool operator<(Arc) const { return false; }
|
| 351 | 351 |
|
| 352 |
/// Converison to Edge |
|
| 353 |
operator Edge() const { return Edge(); }
|
|
| 352 | 354 |
}; |
| 353 | 355 |
/// This iterator goes through each directed arc. |
| 354 | 356 |
|
| 355 | 357 |
/// This iterator goes through each arc of a graph. |
| 356 | 358 |
/// Its usage is quite simple, for example you can count the number |
| 357 | 359 |
/// of arcs in a graph \c g of type \c Graph as follows: |
| 358 | 360 |
///\code |
| 359 | 361 |
/// int count=0; |
| 360 | 362 |
/// for(Graph::ArcIt e(g); e!=INVALID; ++e) ++count; |
| 361 | 363 |
///\endcode |
| 362 | 364 |
class ArcIt : public Arc {
|
| 363 | 365 |
public: |
| 364 | 366 |
/// Default constructor |
| 365 | 367 |
|
| 366 | 368 |
/// @warning The default constructor sets the iterator |
| 367 | 369 |
/// to an undefined value. |
| 368 | 370 |
ArcIt() { }
|
| 369 | 371 |
/// Copy constructor. |
| 370 | 372 |
|
| 371 | 373 |
/// Copy constructor. |
| 372 | 374 |
/// |
| 373 | 375 |
ArcIt(const ArcIt& e) : Arc(e) { }
|
| 374 | 376 |
/// Initialize the iterator to be invalid. |
| 375 | 377 |
|
| 376 | 378 |
/// Initialize the iterator to be invalid. |
| 377 | 379 |
/// |
| 378 | 380 |
ArcIt(Invalid) { }
|
| 379 | 381 |
/// This constructor sets the iterator to the first arc. |
| 380 | 382 |
|
| 381 | 383 |
/// This constructor sets the iterator to the first arc of \c g. |
| 382 | 384 |
///@param g the graph |
| 383 | 385 |
ArcIt(const Graph &g) { ignore_unused_variable_warning(g); }
|
| 384 | 386 |
/// Arc -> ArcIt conversion |
| 385 | 387 |
|
| 386 | 388 |
/// Sets the iterator to the value of the trivial iterator \c e. |
| 387 | 389 |
/// This feature necessitates that each time we |
| 388 | 390 |
/// iterate the arc-set, the iteration order is the same. |
| 389 | 391 |
ArcIt(const Graph&, const Arc&) { }
|
| 390 | 392 |
///Next arc |
| 391 | 393 |
|
| 392 | 394 |
/// Assign the iterator to the next arc. |
| 393 | 395 |
ArcIt& operator++() { return *this; }
|
| 394 | 396 |
}; |
| 395 | 397 |
|
| 396 | 398 |
/// This iterator goes trough the outgoing directed arcs of a node. |
| 397 | 399 |
|
| 398 | 400 |
/// This iterator goes trough the \e outgoing arcs of a certain node |
| 399 | 401 |
/// of a graph. |
| 400 | 402 |
/// Its usage is quite simple, for example you can count the number |
| 401 | 403 |
/// of outgoing arcs of a node \c n |
| 402 | 404 |
/// in graph \c g of type \c Graph as follows. |
| 403 | 405 |
///\code |
| 404 | 406 |
/// int count=0; |
| 405 | 407 |
/// for (Graph::OutArcIt e(g, n); e!=INVALID; ++e) ++count; |
| 406 | 408 |
///\endcode |
| 407 | 409 |
|
| 408 | 410 |
class OutArcIt : public Arc {
|
| 409 | 411 |
public: |
| 410 | 412 |
/// Default constructor |
| 411 | 413 |
|
| 412 | 414 |
/// @warning The default constructor sets the iterator |
| 413 | 415 |
/// to an undefined value. |
| 414 | 416 |
OutArcIt() { }
|
| 415 | 417 |
/// Copy constructor. |
| 416 | 418 |
|
| 417 | 419 |
/// Copy constructor. |
| 418 | 420 |
/// |
| 419 | 421 |
OutArcIt(const OutArcIt& e) : Arc(e) { }
|
| 420 | 422 |
/// Initialize the iterator to be invalid. |
| 421 | 423 |
|
| 422 | 424 |
/// Initialize the iterator to be invalid. |
| 423 | 425 |
/// |
| 424 | 426 |
OutArcIt(Invalid) { }
|
| 425 | 427 |
/// This constructor sets the iterator to the first outgoing arc. |
| 426 | 428 |
|
| 427 | 429 |
/// This constructor sets the iterator to the first outgoing arc of |
| 428 | 430 |
/// the node. |
| 429 | 431 |
///@param n the node |
| 430 | 432 |
///@param g the graph |
| 431 | 433 |
OutArcIt(const Graph& n, const Node& g) {
|
| 432 | 434 |
ignore_unused_variable_warning(n); |
| 433 | 435 |
ignore_unused_variable_warning(g); |
| 434 | 436 |
} |
| 435 | 437 |
/// Arc -> OutArcIt conversion |
| 436 | 438 |
|
| 437 | 439 |
/// Sets the iterator to the value of the trivial iterator. |
| 438 | 440 |
/// This feature necessitates that each time we |
| 439 | 441 |
/// iterate the arc-set, the iteration order is the same. |
| 440 | 442 |
OutArcIt(const Graph&, const Arc&) { }
|
| 441 | 443 |
///Next outgoing arc |
| 442 | 444 |
|
| 443 | 445 |
/// Assign the iterator to the next |
| 444 | 446 |
/// outgoing arc of the corresponding node. |
| 445 | 447 |
OutArcIt& operator++() { return *this; }
|
| 446 | 448 |
}; |
| 447 | 449 |
|
0 comments (0 inline)