0
2
0
... | ... |
@@ -303,151 +303,184 @@ |
303 | 303 |
///\code |
304 | 304 |
/// int count=0; |
305 | 305 |
/// for(Digraph::ArcIt e(g); e!=INVALID; ++e) ++count; |
306 | 306 |
///\endcode |
307 | 307 |
class ArcIt : public Arc { |
308 | 308 |
public: |
309 | 309 |
/// Default constructor |
310 | 310 |
|
311 | 311 |
/// @warning The default constructor sets the iterator |
312 | 312 |
/// to an undefined value. |
313 | 313 |
ArcIt() { } |
314 | 314 |
/// Copy constructor. |
315 | 315 |
|
316 | 316 |
/// Copy constructor. |
317 | 317 |
/// |
318 | 318 |
ArcIt(const ArcIt& e) : Arc(e) { } |
319 | 319 |
/// Initialize the iterator to be invalid. |
320 | 320 |
|
321 | 321 |
/// Initialize the iterator to be invalid. |
322 | 322 |
/// |
323 | 323 |
ArcIt(Invalid) { } |
324 | 324 |
/// This constructor sets the iterator to the first arc. |
325 | 325 |
|
326 | 326 |
/// This constructor sets the iterator to the first arc of \c g. |
327 | 327 |
///@param g the digraph |
328 | 328 |
ArcIt(const Digraph& g) { ignore_unused_variable_warning(g); } |
329 | 329 |
/// Arc -> ArcIt conversion |
330 | 330 |
|
331 | 331 |
/// Sets the iterator to the value of the trivial iterator \c e. |
332 | 332 |
/// This feature necessitates that each time we |
333 | 333 |
/// iterate the arc-set, the iteration order is the same. |
334 | 334 |
ArcIt(const Digraph&, const Arc&) { } |
335 | 335 |
///Next arc |
336 | 336 |
|
337 | 337 |
/// Assign the iterator to the next arc. |
338 | 338 |
ArcIt& operator++() { return *this; } |
339 | 339 |
}; |
340 | 340 |
///Gives back the target node of an arc. |
341 | 341 |
|
342 | 342 |
///Gives back the target node of an arc. |
343 | 343 |
/// |
344 | 344 |
Node target(Arc) const { return INVALID; } |
345 | 345 |
///Gives back the source node of an arc. |
346 | 346 |
|
347 | 347 |
///Gives back the source node of an arc. |
348 | 348 |
/// |
349 | 349 |
Node source(Arc) const { return INVALID; } |
350 | 350 |
|
351 |
/// \brief Returns the ID of the node. |
|
352 |
int id(Node) const { return -1; } |
|
353 |
|
|
354 |
/// \brief Returns the ID of the arc. |
|
355 |
int id(Arc) const { return -1; } |
|
356 |
|
|
357 |
/// \brief Returns the node with the given ID. |
|
358 |
/// |
|
359 |
/// \pre The argument should be a valid node ID in the graph. |
|
360 |
Node nodeFromId(int) const { return INVALID; } |
|
361 |
|
|
362 |
/// \brief Returns the arc with the given ID. |
|
363 |
/// |
|
364 |
/// \pre The argument should be a valid arc ID in the graph. |
|
365 |
Arc arcFromId(int) const { return INVALID; } |
|
366 |
|
|
367 |
/// \brief Returns an upper bound on the node IDs. |
|
368 |
int maxNodeId() const { return -1; } |
|
369 |
|
|
370 |
/// \brief Returns an upper bound on the arc IDs. |
|
371 |
int maxArcId() const { return -1; } |
|
372 |
|
|
351 | 373 |
void first(Node&) const {} |
352 | 374 |
void next(Node&) const {} |
353 | 375 |
|
354 | 376 |
void first(Arc&) const {} |
355 | 377 |
void next(Arc&) const {} |
356 | 378 |
|
357 | 379 |
|
358 | 380 |
void firstIn(Arc&, const Node&) const {} |
359 | 381 |
void nextIn(Arc&) const {} |
360 | 382 |
|
361 | 383 |
void firstOut(Arc&, const Node&) const {} |
362 | 384 |
void nextOut(Arc&) const {} |
363 | 385 |
|
386 |
// The second parameter is dummy. |
|
387 |
Node fromId(int, Node) const { return INVALID; } |
|
388 |
// The second parameter is dummy. |
|
389 |
Arc fromId(int, Arc) const { return INVALID; } |
|
390 |
|
|
391 |
// Dummy parameter. |
|
392 |
int maxId(Node) const { return -1; } |
|
393 |
// Dummy parameter. |
|
394 |
int maxId(Arc) const { return -1; } |
|
395 |
|
|
364 | 396 |
/// \brief The base node of the iterator. |
365 | 397 |
/// |
366 | 398 |
/// Gives back the base node of the iterator. |
367 | 399 |
/// It is always the target of the pointed arc. |
368 | 400 |
Node baseNode(const InArcIt&) const { return INVALID; } |
369 | 401 |
|
370 | 402 |
/// \brief The running node of the iterator. |
371 | 403 |
/// |
372 | 404 |
/// Gives back the running node of the iterator. |
373 | 405 |
/// It is always the source of the pointed arc. |
374 | 406 |
Node runningNode(const InArcIt&) const { return INVALID; } |
375 | 407 |
|
376 | 408 |
/// \brief The base node of the iterator. |
377 | 409 |
/// |
378 | 410 |
/// Gives back the base node of the iterator. |
379 | 411 |
/// It is always the source of the pointed arc. |
380 | 412 |
Node baseNode(const OutArcIt&) const { return INVALID; } |
381 | 413 |
|
382 | 414 |
/// \brief The running node of the iterator. |
383 | 415 |
/// |
384 | 416 |
/// Gives back the running node of the iterator. |
385 | 417 |
/// It is always the target of the pointed arc. |
386 | 418 |
Node runningNode(const OutArcIt&) const { return INVALID; } |
387 | 419 |
|
388 | 420 |
/// \brief The opposite node on the given arc. |
389 | 421 |
/// |
390 | 422 |
/// Gives back the opposite node on the given arc. |
391 | 423 |
Node oppositeNode(const Node&, const Arc&) const { return INVALID; } |
392 | 424 |
|
393 | 425 |
/// \brief Read write map of the nodes to type \c T. |
394 | 426 |
/// |
395 | 427 |
/// ReadWrite map of the nodes to type \c T. |
396 | 428 |
/// \sa Reference |
397 | 429 |
template<class T> |
398 | 430 |
class NodeMap : public ReadWriteMap< Node, T > { |
399 | 431 |
public: |
400 | 432 |
|
401 | 433 |
///\e |
402 | 434 |
NodeMap(const Digraph&) { } |
403 | 435 |
///\e |
404 | 436 |
NodeMap(const Digraph&, T) { } |
405 | 437 |
|
406 | 438 |
///Copy constructor |
407 | 439 |
NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { } |
408 | 440 |
///Assignment operator |
409 | 441 |
template <typename CMap> |
410 | 442 |
NodeMap& operator=(const CMap&) { |
411 | 443 |
checkConcept<ReadMap<Node, T>, CMap>(); |
412 | 444 |
return *this; |
413 | 445 |
} |
414 | 446 |
}; |
415 | 447 |
|
416 | 448 |
/// \brief Read write map of the arcs to type \c T. |
417 | 449 |
/// |
418 | 450 |
/// Reference map of the arcs to type \c T. |
419 | 451 |
/// \sa Reference |
420 | 452 |
template<class T> |
421 | 453 |
class ArcMap : public ReadWriteMap<Arc,T> { |
422 | 454 |
public: |
423 | 455 |
|
424 | 456 |
///\e |
425 | 457 |
ArcMap(const Digraph&) { } |
426 | 458 |
///\e |
427 | 459 |
ArcMap(const Digraph&, T) { } |
428 | 460 |
///Copy constructor |
429 | 461 |
ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { } |
430 | 462 |
///Assignment operator |
431 | 463 |
template <typename CMap> |
432 | 464 |
ArcMap& operator=(const CMap&) { |
433 | 465 |
checkConcept<ReadMap<Arc, T>, CMap>(); |
434 | 466 |
return *this; |
435 | 467 |
} |
436 | 468 |
}; |
437 | 469 |
|
438 | 470 |
template <typename RDigraph> |
439 | 471 |
struct Constraints { |
440 | 472 |
void constraints() { |
441 | 473 |
checkConcept<IterableDigraphComponent<>, Digraph>(); |
474 |
checkConcept<IDableDigraphComponent<>, Digraph>(); |
|
442 | 475 |
checkConcept<MappableDigraphComponent<>, Digraph>(); |
443 | 476 |
} |
444 | 477 |
}; |
445 | 478 |
|
446 | 479 |
}; |
447 | 480 |
|
448 | 481 |
} //namespace concepts |
449 | 482 |
} //namespace lemon |
450 | 483 |
|
451 | 484 |
|
452 | 485 |
|
453 | 486 |
#endif // LEMON_CONCEPT_DIGRAPH_H |
... | ... |
@@ -579,124 +579,171 @@ |
579 | 579 |
/// \brief Direct the given edge. |
580 | 580 |
/// |
581 | 581 |
/// Direct the given edge. The returned arc |
582 | 582 |
/// represents the given edge and the direction comes |
583 | 583 |
/// from the bool parameter. The source of the edge and |
584 | 584 |
/// the directed arc is the same when the given bool is true. |
585 | 585 |
Arc direct(const Edge&, bool) const { |
586 | 586 |
return INVALID; |
587 | 587 |
} |
588 | 588 |
|
589 | 589 |
/// \brief Returns true if the arc has default orientation. |
590 | 590 |
/// |
591 | 591 |
/// Returns whether the given directed arc is same orientation as |
592 | 592 |
/// the corresponding edge's default orientation. |
593 | 593 |
bool direction(Arc) const { return true; } |
594 | 594 |
|
595 | 595 |
/// \brief Returns the opposite directed arc. |
596 | 596 |
/// |
597 | 597 |
/// Returns the opposite directed arc. |
598 | 598 |
Arc oppositeArc(Arc) const { return INVALID; } |
599 | 599 |
|
600 | 600 |
/// \brief Opposite node on an arc |
601 | 601 |
/// |
602 | 602 |
/// \return the opposite of the given Node on the given Edge |
603 | 603 |
Node oppositeNode(Node, Edge) const { return INVALID; } |
604 | 604 |
|
605 | 605 |
/// \brief First node of the edge. |
606 | 606 |
/// |
607 | 607 |
/// \return the first node of the given Edge. |
608 | 608 |
/// |
609 | 609 |
/// Naturally edges don't have direction and thus |
610 | 610 |
/// don't have source and target node. But we use these two methods |
611 | 611 |
/// to query the two nodes of the arc. The direction of the arc |
612 | 612 |
/// which arises this way is called the inherent direction of the |
613 | 613 |
/// edge, and is used to define the "default" direction |
614 | 614 |
/// of the directed versions of the arcs. |
615 | 615 |
/// \sa direction |
616 | 616 |
Node u(Edge) const { return INVALID; } |
617 | 617 |
|
618 | 618 |
/// \brief Second node of the edge. |
619 | 619 |
Node v(Edge) const { return INVALID; } |
620 | 620 |
|
621 | 621 |
/// \brief Source node of the directed arc. |
622 | 622 |
Node source(Arc) const { return INVALID; } |
623 | 623 |
|
624 | 624 |
/// \brief Target node of the directed arc. |
625 | 625 |
Node target(Arc) const { return INVALID; } |
626 | 626 |
|
627 |
/// \brief Returns the id of the node. |
|
628 |
int id(Node) const { return -1; } |
|
629 |
|
|
630 |
/// \brief Returns the id of the edge. |
|
631 |
int id(Edge) const { return -1; } |
|
632 |
|
|
633 |
/// \brief Returns the id of the arc. |
|
634 |
int id(Arc) const { return -1; } |
|
635 |
|
|
636 |
/// \brief Returns the node with the given id. |
|
637 |
/// |
|
638 |
/// \pre The argument should be a valid node id in the graph. |
|
639 |
Node nodeFromId(int) const { return INVALID; } |
|
640 |
|
|
641 |
/// \brief Returns the edge with the given id. |
|
642 |
/// |
|
643 |
/// \pre The argument should be a valid edge id in the graph. |
|
644 |
Edge edgeFromId(int) const { return INVALID; } |
|
645 |
|
|
646 |
/// \brief Returns the arc with the given id. |
|
647 |
/// |
|
648 |
/// \pre The argument should be a valid arc id in the graph. |
|
649 |
Arc arcFromId(int) const { return INVALID; } |
|
650 |
|
|
651 |
/// \brief Returns an upper bound on the node IDs. |
|
652 |
int maxNodeId() const { return -1; } |
|
653 |
|
|
654 |
/// \brief Returns an upper bound on the edge IDs. |
|
655 |
int maxEdgeId() const { return -1; } |
|
656 |
|
|
657 |
/// \brief Returns an upper bound on the arc IDs. |
|
658 |
int maxArcId() const { return -1; } |
|
659 |
|
|
627 | 660 |
void first(Node&) const {} |
628 | 661 |
void next(Node&) const {} |
629 | 662 |
|
630 | 663 |
void first(Edge&) const {} |
631 | 664 |
void next(Edge&) const {} |
632 | 665 |
|
633 | 666 |
void first(Arc&) const {} |
634 | 667 |
void next(Arc&) const {} |
635 | 668 |
|
636 | 669 |
void firstOut(Arc&, Node) const {} |
637 | 670 |
void nextOut(Arc&) const {} |
638 | 671 |
|
639 | 672 |
void firstIn(Arc&, Node) const {} |
640 | 673 |
void nextIn(Arc&) const {} |
641 | 674 |
|
642 |
|
|
643 | 675 |
void firstInc(Edge &, bool &, const Node &) const {} |
644 | 676 |
void nextInc(Edge &, bool &) const {} |
645 | 677 |
|
678 |
// The second parameter is dummy. |
|
679 |
Node fromId(int, Node) const { return INVALID; } |
|
680 |
// The second parameter is dummy. |
|
681 |
Edge fromId(int, Edge) const { return INVALID; } |
|
682 |
// The second parameter is dummy. |
|
683 |
Arc fromId(int, Arc) const { return INVALID; } |
|
684 |
|
|
685 |
// Dummy parameter. |
|
686 |
int maxId(Node) const { return -1; } |
|
687 |
// Dummy parameter. |
|
688 |
int maxId(Edge) const { return -1; } |
|
689 |
// Dummy parameter. |
|
690 |
int maxId(Arc) const { return -1; } |
|
691 |
|
|
646 | 692 |
/// \brief Base node of the iterator |
647 | 693 |
/// |
648 | 694 |
/// Returns the base node (the source in this case) of the iterator |
649 | 695 |
Node baseNode(OutArcIt e) const { |
650 | 696 |
return source(e); |
651 | 697 |
} |
652 | 698 |
/// \brief Running node of the iterator |
653 | 699 |
/// |
654 | 700 |
/// Returns the running node (the target in this case) of the |
655 | 701 |
/// iterator |
656 | 702 |
Node runningNode(OutArcIt e) const { |
657 | 703 |
return target(e); |
658 | 704 |
} |
659 | 705 |
|
660 | 706 |
/// \brief Base node of the iterator |
661 | 707 |
/// |
662 | 708 |
/// Returns the base node (the target in this case) of the iterator |
663 | 709 |
Node baseNode(InArcIt e) const { |
664 | 710 |
return target(e); |
665 | 711 |
} |
666 | 712 |
/// \brief Running node of the iterator |
667 | 713 |
/// |
668 | 714 |
/// Returns the running node (the source in this case) of the |
669 | 715 |
/// iterator |
670 | 716 |
Node runningNode(InArcIt e) const { |
671 | 717 |
return source(e); |
672 | 718 |
} |
673 | 719 |
|
674 | 720 |
/// \brief Base node of the iterator |
675 | 721 |
/// |
676 | 722 |
/// Returns the base node of the iterator |
677 | 723 |
Node baseNode(IncArcIt) const { |
678 | 724 |
return INVALID; |
679 | 725 |
} |
680 | 726 |
|
681 | 727 |
/// \brief Running node of the iterator |
682 | 728 |
/// |
683 | 729 |
/// Returns the running node of the iterator |
684 | 730 |
Node runningNode(IncArcIt) const { |
685 | 731 |
return INVALID; |
686 | 732 |
} |
687 | 733 |
|
688 | 734 |
template <typename Graph> |
689 | 735 |
struct Constraints { |
690 | 736 |
void constraints() { |
691 | 737 |
checkConcept<IterableGraphComponent<>, Graph>(); |
738 |
checkConcept<IDableGraphComponent<>, Graph>(); |
|
692 | 739 |
checkConcept<MappableGraphComponent<>, Graph>(); |
693 | 740 |
} |
694 | 741 |
}; |
695 | 742 |
|
696 | 743 |
}; |
697 | 744 |
|
698 | 745 |
} |
699 | 746 |
|
700 | 747 |
} |
701 | 748 |
|
702 | 749 |
#endif |
0 comments (0 inline)