gravatar
kpeter (Peter Kovacs)
kpeter@inf.elte.hu
Various improvements and fixes (mainly in the doc) (#190)
0 2 0
default
2 files changed with 441 insertions and 429 deletions:
↑ Collapse diff ↑
Ignore white space 1536 line context
... ...
@@ -1427,1536 +1427,1539 @@
1427 1427
  template<typename GR, typename NF, typename EF>
1428 1428
  SubGraph<const GR, const NF, EF>
1429 1429
  subGraph(const GR& graph, const NF& node_filter, EF& edge_filter) {
1430 1430
    return SubGraph<const GR, const NF, EF>
1431 1431
      (graph, node_filter, edge_filter);
1432 1432
  }
1433 1433

	
1434 1434
  template<typename GR, typename NF, typename EF>
1435 1435
  SubGraph<const GR, NF, const EF>
1436 1436
  subGraph(const GR& graph, NF& node_filter, const EF& edge_filter) {
1437 1437
    return SubGraph<const GR, NF, const EF>
1438 1438
      (graph, node_filter, edge_filter);
1439 1439
  }
1440 1440

	
1441 1441
  template<typename GR, typename NF, typename EF>
1442 1442
  SubGraph<const GR, const NF, const EF>
1443 1443
  subGraph(const GR& graph, const NF& node_filter, const EF& edge_filter) {
1444 1444
    return SubGraph<const GR, const NF, const EF>
1445 1445
      (graph, node_filter, edge_filter);
1446 1446
  }
1447 1447

	
1448 1448

	
1449 1449
  /// \ingroup graph_adaptors
1450 1450
  ///
1451 1451
  /// \brief Adaptor class for hiding nodes in a digraph or a graph.
1452 1452
  ///
1453 1453
  /// FilterNodes adaptor can be used for hiding nodes in a digraph or a
1454 1454
  /// graph. A \c bool node map must be specified, which defines the filter
1455 1455
  /// for the nodes. Only the nodes with \c true filter value and the
1456 1456
  /// arcs/edges incident to nodes both with \c true filter value are shown
1457 1457
  /// in the subgraph. This adaptor conforms to the \ref concepts::Digraph
1458 1458
  /// "Digraph" concept or the \ref concepts::Graph "Graph" concept
1459 1459
  /// depending on the \c GR template parameter.
1460 1460
  ///
1461 1461
  /// The adapted (di)graph can also be modified through this adaptor
1462 1462
  /// by adding or removing nodes or arcs/edges, unless the \c GR template
1463 1463
  /// parameter is set to be \c const.
1464 1464
  ///
1465 1465
  /// \tparam GR The type of the adapted digraph or graph.
1466 1466
  /// It must conform to the \ref concepts::Digraph "Digraph" concept
1467 1467
  /// or the \ref concepts::Graph "Graph" concept.
1468 1468
  /// It can also be specified to be \c const.
1469 1469
  /// \tparam NF The type of the node filter map.
1470 1470
  /// It must be a \c bool (or convertible) node map of the
1471 1471
  /// adapted (di)graph. The default type is
1472 1472
  /// \ref concepts::Graph::NodeMap "GR::NodeMap<bool>".
1473 1473
  ///
1474 1474
  /// \note The \c Node and <tt>Arc/Edge</tt> types of this adaptor and the
1475 1475
  /// adapted (di)graph are convertible to each other.
1476 1476
#ifdef DOXYGEN
1477 1477
  template<typename GR, typename NF>
1478 1478
  class FilterNodes {
1479 1479
#else
1480 1480
  template<typename GR,
1481 1481
           typename NF = typename GR::template NodeMap<bool>,
1482 1482
           typename Enable = void>
1483 1483
  class FilterNodes :
1484 1484
    public DigraphAdaptorExtender<
1485 1485
      SubDigraphBase<GR, NF, ConstMap<typename GR::Arc, Const<bool, true> >,
1486 1486
                     true> > {
1487 1487
#endif
1488 1488
  public:
1489 1489

	
1490 1490
    typedef GR Digraph;
1491 1491
    typedef NF NodeFilterMap;
1492 1492

	
1493 1493
    typedef DigraphAdaptorExtender<
1494 1494
      SubDigraphBase<GR, NF, ConstMap<typename GR::Arc, Const<bool, true> >, 
1495 1495
                     true> > Parent;
1496 1496

	
1497 1497
    typedef typename Parent::Node Node;
1498 1498

	
1499 1499
  protected:
1500 1500
    ConstMap<typename Digraph::Arc, Const<bool, true> > const_true_map;
1501 1501

	
1502 1502
    FilterNodes() : const_true_map() {}
1503 1503

	
1504 1504
  public:
1505 1505

	
1506 1506
    /// \brief Constructor
1507 1507
    ///
1508 1508
    /// Creates a subgraph for the given digraph or graph with the
1509 1509
    /// given node filter map.
1510 1510
    FilterNodes(GR& graph, NF& node_filter) 
1511 1511
      : Parent(), const_true_map()
1512 1512
    {
1513 1513
      Parent::initialize(graph, node_filter, const_true_map);
1514 1514
    }
1515 1515

	
1516 1516
    /// \brief Sets the status of the given node
1517 1517
    ///
1518 1518
    /// This function sets the status of the given node.
1519 1519
    /// It is done by simply setting the assigned value of \c n
1520 1520
    /// to \c v in the node filter map.
1521 1521
    void status(const Node& n, bool v) const { Parent::status(n, v); }
1522 1522

	
1523 1523
    /// \brief Returns the status of the given node
1524 1524
    ///
1525 1525
    /// This function returns the status of the given node.
1526 1526
    /// It is \c true if the given node is enabled (i.e. not hidden).
1527 1527
    bool status(const Node& n) const { return Parent::status(n); }
1528 1528

	
1529 1529
    /// \brief Disables the given node
1530 1530
    ///
1531 1531
    /// This function disables the given node, so the iteration
1532 1532
    /// jumps over it.
1533 1533
    /// It is the same as \ref status() "status(n, false)".
1534 1534
    void disable(const Node& n) const { Parent::status(n, false); }
1535 1535

	
1536 1536
    /// \brief Enables the given node
1537 1537
    ///
1538 1538
    /// This function enables the given node.
1539 1539
    /// It is the same as \ref status() "status(n, true)".
1540 1540
    void enable(const Node& n) const { Parent::status(n, true); }
1541 1541

	
1542 1542
  };
1543 1543

	
1544 1544
  template<typename GR, typename NF>
1545 1545
  class FilterNodes<GR, NF,
1546 1546
                    typename enable_if<UndirectedTagIndicator<GR> >::type> :
1547 1547
    public GraphAdaptorExtender<
1548 1548
      SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >, 
1549 1549
                   true> > {
1550 1550

	
1551 1551
  public:
1552 1552
    typedef GR Graph;
1553 1553
    typedef NF NodeFilterMap;
1554 1554
    typedef GraphAdaptorExtender<
1555 1555
      SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >, 
1556 1556
                   true> > Parent;
1557 1557

	
1558 1558
    typedef typename Parent::Node Node;
1559 1559
  protected:
1560 1560
    ConstMap<typename GR::Edge, Const<bool, true> > const_true_map;
1561 1561

	
1562 1562
    FilterNodes() : const_true_map() {}
1563 1563

	
1564 1564
  public:
1565 1565

	
1566 1566
    FilterNodes(GR& graph, NodeFilterMap& node_filter) :
1567 1567
      Parent(), const_true_map() {
1568 1568
      Parent::initialize(graph, node_filter, const_true_map);
1569 1569
    }
1570 1570

	
1571 1571
    void status(const Node& n, bool v) const { Parent::status(n, v); }
1572 1572
    bool status(const Node& n) const { return Parent::status(n); }
1573 1573
    void disable(const Node& n) const { Parent::status(n, false); }
1574 1574
    void enable(const Node& n) const { Parent::status(n, true); }
1575 1575

	
1576 1576
  };
1577 1577

	
1578 1578

	
1579 1579
  /// \brief Returns a read-only FilterNodes adaptor
1580 1580
  ///
1581 1581
  /// This function just returns a read-only \ref FilterNodes adaptor.
1582 1582
  /// \ingroup graph_adaptors
1583 1583
  /// \relates FilterNodes
1584 1584
  template<typename GR, typename NF>
1585 1585
  FilterNodes<const GR, NF>
1586 1586
  filterNodes(const GR& graph, NF& node_filter) {
1587 1587
    return FilterNodes<const GR, NF>(graph, node_filter);
1588 1588
  }
1589 1589

	
1590 1590
  template<typename GR, typename NF>
1591 1591
  FilterNodes<const GR, const NF>
1592 1592
  filterNodes(const GR& graph, const NF& node_filter) {
1593 1593
    return FilterNodes<const GR, const NF>(graph, node_filter);
1594 1594
  }
1595 1595

	
1596 1596
  /// \ingroup graph_adaptors
1597 1597
  ///
1598 1598
  /// \brief Adaptor class for hiding arcs in a digraph.
1599 1599
  ///
1600 1600
  /// FilterArcs adaptor can be used for hiding arcs in a digraph.
1601 1601
  /// A \c bool arc map must be specified, which defines the filter for
1602 1602
  /// the arcs. Only the arcs with \c true filter value are shown in the
1603 1603
  /// subdigraph. This adaptor conforms to the \ref concepts::Digraph
1604 1604
  /// "Digraph" concept.
1605 1605
  ///
1606 1606
  /// The adapted digraph can also be modified through this adaptor
1607 1607
  /// by adding or removing nodes or arcs, unless the \c GR template
1608 1608
  /// parameter is set to be \c const.
1609 1609
  ///
1610 1610
  /// \tparam DGR The type of the adapted digraph.
1611 1611
  /// It must conform to the \ref concepts::Digraph "Digraph" concept.
1612 1612
  /// It can also be specified to be \c const.
1613 1613
  /// \tparam AF The type of the arc filter map.
1614 1614
  /// It must be a \c bool (or convertible) arc map of the
1615 1615
  /// adapted digraph. The default type is
1616 1616
  /// \ref concepts::Digraph::ArcMap "DGR::ArcMap<bool>".
1617 1617
  ///
1618 1618
  /// \note The \c Node and \c Arc types of this adaptor and the adapted
1619 1619
  /// digraph are convertible to each other.
1620 1620
#ifdef DOXYGEN
1621 1621
  template<typename DGR,
1622 1622
           typename AF>
1623 1623
  class FilterArcs {
1624 1624
#else
1625 1625
  template<typename DGR,
1626 1626
           typename AF = typename DGR::template ArcMap<bool> >
1627 1627
  class FilterArcs :
1628 1628
    public DigraphAdaptorExtender<
1629 1629
      SubDigraphBase<DGR, ConstMap<typename DGR::Node, Const<bool, true> >,
1630 1630
                     AF, false> > {
1631 1631
#endif
1632 1632
  public:
1633 1633
    /// The type of the adapted digraph.
1634 1634
    typedef DGR Digraph;
1635 1635
    /// The type of the arc filter map.
1636 1636
    typedef AF ArcFilterMap;
1637 1637

	
1638 1638
    typedef DigraphAdaptorExtender<
1639 1639
      SubDigraphBase<DGR, ConstMap<typename DGR::Node, Const<bool, true> >, 
1640 1640
                     AF, false> > Parent;
1641 1641

	
1642 1642
    typedef typename Parent::Arc Arc;
1643 1643

	
1644 1644
  protected:
1645 1645
    ConstMap<typename DGR::Node, Const<bool, true> > const_true_map;
1646 1646

	
1647 1647
    FilterArcs() : const_true_map() {}
1648 1648

	
1649 1649
  public:
1650 1650

	
1651 1651
    /// \brief Constructor
1652 1652
    ///
1653 1653
    /// Creates a subdigraph for the given digraph with the given arc
1654 1654
    /// filter map.
1655 1655
    FilterArcs(DGR& digraph, ArcFilterMap& arc_filter)
1656 1656
      : Parent(), const_true_map() {
1657 1657
      Parent::initialize(digraph, const_true_map, arc_filter);
1658 1658
    }
1659 1659

	
1660 1660
    /// \brief Sets the status of the given arc
1661 1661
    ///
1662 1662
    /// This function sets the status of the given arc.
1663 1663
    /// It is done by simply setting the assigned value of \c a
1664 1664
    /// to \c v in the arc filter map.
1665 1665
    void status(const Arc& a, bool v) const { Parent::status(a, v); }
1666 1666

	
1667 1667
    /// \brief Returns the status of the given arc
1668 1668
    ///
1669 1669
    /// This function returns the status of the given arc.
1670 1670
    /// It is \c true if the given arc is enabled (i.e. not hidden).
1671 1671
    bool status(const Arc& a) const { return Parent::status(a); }
1672 1672

	
1673 1673
    /// \brief Disables the given arc
1674 1674
    ///
1675 1675
    /// This function disables the given arc in the subdigraph,
1676 1676
    /// so the iteration jumps over it.
1677 1677
    /// It is the same as \ref status() "status(a, false)".
1678 1678
    void disable(const Arc& a) const { Parent::status(a, false); }
1679 1679

	
1680 1680
    /// \brief Enables the given arc
1681 1681
    ///
1682 1682
    /// This function enables the given arc in the subdigraph.
1683 1683
    /// It is the same as \ref status() "status(a, true)".
1684 1684
    void enable(const Arc& a) const { Parent::status(a, true); }
1685 1685

	
1686 1686
  };
1687 1687

	
1688 1688
  /// \brief Returns a read-only FilterArcs adaptor
1689 1689
  ///
1690 1690
  /// This function just returns a read-only \ref FilterArcs adaptor.
1691 1691
  /// \ingroup graph_adaptors
1692 1692
  /// \relates FilterArcs
1693 1693
  template<typename DGR, typename AF>
1694 1694
  FilterArcs<const DGR, AF>
1695 1695
  filterArcs(const DGR& digraph, AF& arc_filter) {
1696 1696
    return FilterArcs<const DGR, AF>(digraph, arc_filter);
1697 1697
  }
1698 1698

	
1699 1699
  template<typename DGR, typename AF>
1700 1700
  FilterArcs<const DGR, const AF>
1701 1701
  filterArcs(const DGR& digraph, const AF& arc_filter) {
1702 1702
    return FilterArcs<const DGR, const AF>(digraph, arc_filter);
1703 1703
  }
1704 1704

	
1705 1705
  /// \ingroup graph_adaptors
1706 1706
  ///
1707 1707
  /// \brief Adaptor class for hiding edges in a graph.
1708 1708
  ///
1709 1709
  /// FilterEdges adaptor can be used for hiding edges in a graph.
1710 1710
  /// A \c bool edge map must be specified, which defines the filter for
1711 1711
  /// the edges. Only the edges with \c true filter value are shown in the
1712 1712
  /// subgraph. This adaptor conforms to the \ref concepts::Graph
1713 1713
  /// "Graph" concept.
1714 1714
  ///
1715 1715
  /// The adapted graph can also be modified through this adaptor
1716 1716
  /// by adding or removing nodes or edges, unless the \c GR template
1717 1717
  /// parameter is set to be \c const.
1718 1718
  ///
1719 1719
  /// \tparam GR The type of the adapted graph.
1720 1720
  /// It must conform to the \ref concepts::Graph "Graph" concept.
1721 1721
  /// It can also be specified to be \c const.
1722 1722
  /// \tparam EF The type of the edge filter map.
1723 1723
  /// It must be a \c bool (or convertible) edge map of the
1724 1724
  /// adapted graph. The default type is
1725 1725
  /// \ref concepts::Graph::EdgeMap "GR::EdgeMap<bool>".
1726 1726
  ///
1727 1727
  /// \note The \c Node, \c Edge and \c Arc types of this adaptor and the
1728 1728
  /// adapted graph are convertible to each other.
1729 1729
#ifdef DOXYGEN
1730 1730
  template<typename GR,
1731 1731
           typename EF>
1732 1732
  class FilterEdges {
1733 1733
#else
1734 1734
  template<typename GR,
1735 1735
           typename EF = typename GR::template EdgeMap<bool> >
1736 1736
  class FilterEdges :
1737 1737
    public GraphAdaptorExtender<
1738 1738
      SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true> >, 
1739 1739
                   EF, false> > {
1740 1740
#endif
1741 1741
  public:
1742 1742
    /// The type of the adapted graph.
1743 1743
    typedef GR Graph;
1744 1744
    /// The type of the edge filter map.
1745 1745
    typedef EF EdgeFilterMap;
1746 1746

	
1747 1747
    typedef GraphAdaptorExtender<
1748 1748
      SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true > >, 
1749 1749
                   EF, false> > Parent;
1750 1750

	
1751 1751
    typedef typename Parent::Edge Edge;
1752 1752

	
1753 1753
  protected:
1754 1754
    ConstMap<typename GR::Node, Const<bool, true> > const_true_map;
1755 1755

	
1756 1756
    FilterEdges() : const_true_map(true) {
1757 1757
      Parent::setNodeFilterMap(const_true_map);
1758 1758
    }
1759 1759

	
1760 1760
  public:
1761 1761

	
1762 1762
    /// \brief Constructor
1763 1763
    ///
1764 1764
    /// Creates a subgraph for the given graph with the given edge
1765 1765
    /// filter map.
1766 1766
    FilterEdges(GR& graph, EF& edge_filter) 
1767 1767
      : Parent(), const_true_map() {
1768 1768
      Parent::initialize(graph, const_true_map, edge_filter);
1769 1769
    }
1770 1770

	
1771 1771
    /// \brief Sets the status of the given edge
1772 1772
    ///
1773 1773
    /// This function sets the status of the given edge.
1774 1774
    /// It is done by simply setting the assigned value of \c e
1775 1775
    /// to \c v in the edge filter map.
1776 1776
    void status(const Edge& e, bool v) const { Parent::status(e, v); }
1777 1777

	
1778 1778
    /// \brief Returns the status of the given edge
1779 1779
    ///
1780 1780
    /// This function returns the status of the given edge.
1781 1781
    /// It is \c true if the given edge is enabled (i.e. not hidden).
1782 1782
    bool status(const Edge& e) const { return Parent::status(e); }
1783 1783

	
1784 1784
    /// \brief Disables the given edge
1785 1785
    ///
1786 1786
    /// This function disables the given edge in the subgraph,
1787 1787
    /// so the iteration jumps over it.
1788 1788
    /// It is the same as \ref status() "status(e, false)".
1789 1789
    void disable(const Edge& e) const { Parent::status(e, false); }
1790 1790

	
1791 1791
    /// \brief Enables the given edge
1792 1792
    ///
1793 1793
    /// This function enables the given edge in the subgraph.
1794 1794
    /// It is the same as \ref status() "status(e, true)".
1795 1795
    void enable(const Edge& e) const { Parent::status(e, true); }
1796 1796

	
1797 1797
  };
1798 1798

	
1799 1799
  /// \brief Returns a read-only FilterEdges adaptor
1800 1800
  ///
1801 1801
  /// This function just returns a read-only \ref FilterEdges adaptor.
1802 1802
  /// \ingroup graph_adaptors
1803 1803
  /// \relates FilterEdges
1804 1804
  template<typename GR, typename EF>
1805 1805
  FilterEdges<const GR, EF>
1806 1806
  filterEdges(const GR& graph, EF& edge_filter) {
1807 1807
    return FilterEdges<const GR, EF>(graph, edge_filter);
1808 1808
  }
1809 1809

	
1810 1810
  template<typename GR, typename EF>
1811 1811
  FilterEdges<const GR, const EF>
1812 1812
  filterEdges(const GR& graph, const EF& edge_filter) {
1813 1813
    return FilterEdges<const GR, const EF>(graph, edge_filter);
1814 1814
  }
1815 1815

	
1816 1816

	
1817 1817
  template <typename DGR>
1818 1818
  class UndirectorBase {
1819 1819
  public:
1820 1820
    typedef DGR Digraph;
1821 1821
    typedef UndirectorBase Adaptor;
1822 1822

	
1823 1823
    typedef True UndirectedTag;
1824 1824

	
1825 1825
    typedef typename Digraph::Arc Edge;
1826 1826
    typedef typename Digraph::Node Node;
1827 1827

	
1828 1828
    class Arc : public Edge {
1829 1829
      friend class UndirectorBase;
1830 1830
    protected:
1831 1831
      bool _forward;
1832 1832

	
1833 1833
      Arc(const Edge& edge, bool forward) :
1834 1834
        Edge(edge), _forward(forward) {}
1835 1835

	
1836 1836
    public:
1837 1837
      Arc() {}
1838 1838

	
1839 1839
      Arc(Invalid) : Edge(INVALID), _forward(true) {}
1840 1840

	
1841 1841
      bool operator==(const Arc &other) const {
1842 1842
        return _forward == other._forward &&
1843 1843
          static_cast<const Edge&>(*this) == static_cast<const Edge&>(other);
1844 1844
      }
1845 1845
      bool operator!=(const Arc &other) const {
1846 1846
        return _forward != other._forward ||
1847 1847
          static_cast<const Edge&>(*this) != static_cast<const Edge&>(other);
1848 1848
      }
1849 1849
      bool operator<(const Arc &other) const {
1850 1850
        return _forward < other._forward ||
1851 1851
          (_forward == other._forward &&
1852 1852
           static_cast<const Edge&>(*this) < static_cast<const Edge&>(other));
1853 1853
      }
1854 1854
    };
1855 1855

	
1856 1856
    void first(Node& n) const {
1857 1857
      _digraph->first(n);
1858 1858
    }
1859 1859

	
1860 1860
    void next(Node& n) const {
1861 1861
      _digraph->next(n);
1862 1862
    }
1863 1863

	
1864 1864
    void first(Arc& a) const {
1865 1865
      _digraph->first(a);
1866 1866
      a._forward = true;
1867 1867
    }
1868 1868

	
1869 1869
    void next(Arc& a) const {
1870 1870
      if (a._forward) {
1871 1871
        a._forward = false;
1872 1872
      } else {
1873 1873
        _digraph->next(a);
1874 1874
        a._forward = true;
1875 1875
      }
1876 1876
    }
1877 1877

	
1878 1878
    void first(Edge& e) const {
1879 1879
      _digraph->first(e);
1880 1880
    }
1881 1881

	
1882 1882
    void next(Edge& e) const {
1883 1883
      _digraph->next(e);
1884 1884
    }
1885 1885

	
1886 1886
    void firstOut(Arc& a, const Node& n) const {
1887 1887
      _digraph->firstIn(a, n);
1888 1888
      if( static_cast<const Edge&>(a) != INVALID ) {
1889 1889
        a._forward = false;
1890 1890
      } else {
1891 1891
        _digraph->firstOut(a, n);
1892 1892
        a._forward = true;
1893 1893
      }
1894 1894
    }
1895 1895
    void nextOut(Arc &a) const {
1896 1896
      if (!a._forward) {
1897 1897
        Node n = _digraph->target(a);
1898 1898
        _digraph->nextIn(a);
1899 1899
        if (static_cast<const Edge&>(a) == INVALID ) {
1900 1900
          _digraph->firstOut(a, n);
1901 1901
          a._forward = true;
1902 1902
        }
1903 1903
      }
1904 1904
      else {
1905 1905
        _digraph->nextOut(a);
1906 1906
      }
1907 1907
    }
1908 1908

	
1909 1909
    void firstIn(Arc &a, const Node &n) const {
1910 1910
      _digraph->firstOut(a, n);
1911 1911
      if (static_cast<const Edge&>(a) != INVALID ) {
1912 1912
        a._forward = false;
1913 1913
      } else {
1914 1914
        _digraph->firstIn(a, n);
1915 1915
        a._forward = true;
1916 1916
      }
1917 1917
    }
1918 1918
    void nextIn(Arc &a) const {
1919 1919
      if (!a._forward) {
1920 1920
        Node n = _digraph->source(a);
1921 1921
        _digraph->nextOut(a);
1922 1922
        if( static_cast<const Edge&>(a) == INVALID ) {
1923 1923
          _digraph->firstIn(a, n);
1924 1924
          a._forward = true;
1925 1925
        }
1926 1926
      }
1927 1927
      else {
1928 1928
        _digraph->nextIn(a);
1929 1929
      }
1930 1930
    }
1931 1931

	
1932 1932
    void firstInc(Edge &e, bool &d, const Node &n) const {
1933 1933
      d = true;
1934 1934
      _digraph->firstOut(e, n);
1935 1935
      if (e != INVALID) return;
1936 1936
      d = false;
1937 1937
      _digraph->firstIn(e, n);
1938 1938
    }
1939 1939

	
1940 1940
    void nextInc(Edge &e, bool &d) const {
1941 1941
      if (d) {
1942 1942
        Node s = _digraph->source(e);
1943 1943
        _digraph->nextOut(e);
1944 1944
        if (e != INVALID) return;
1945 1945
        d = false;
1946 1946
        _digraph->firstIn(e, s);
1947 1947
      } else {
1948 1948
        _digraph->nextIn(e);
1949 1949
      }
1950 1950
    }
1951 1951

	
1952 1952
    Node u(const Edge& e) const {
1953 1953
      return _digraph->source(e);
1954 1954
    }
1955 1955

	
1956 1956
    Node v(const Edge& e) const {
1957 1957
      return _digraph->target(e);
1958 1958
    }
1959 1959

	
1960 1960
    Node source(const Arc &a) const {
1961 1961
      return a._forward ? _digraph->source(a) : _digraph->target(a);
1962 1962
    }
1963 1963

	
1964 1964
    Node target(const Arc &a) const {
1965 1965
      return a._forward ? _digraph->target(a) : _digraph->source(a);
1966 1966
    }
1967 1967

	
1968 1968
    static Arc direct(const Edge &e, bool d) {
1969 1969
      return Arc(e, d);
1970 1970
    }
1971 1971
    Arc direct(const Edge &e, const Node& n) const {
1972 1972
      return Arc(e, _digraph->source(e) == n);
1973 1973
    }
1974 1974

	
1975 1975
    static bool direction(const Arc &a) { return a._forward; }
1976 1976

	
1977 1977
    Node nodeFromId(int ix) const { return _digraph->nodeFromId(ix); }
1978 1978
    Arc arcFromId(int ix) const {
1979 1979
      return direct(_digraph->arcFromId(ix >> 1), bool(ix & 1));
1980 1980
    }
1981 1981
    Edge edgeFromId(int ix) const { return _digraph->arcFromId(ix); }
1982 1982

	
1983 1983
    int id(const Node &n) const { return _digraph->id(n); }
1984 1984
    int id(const Arc &a) const {
1985 1985
      return  (_digraph->id(a) << 1) | (a._forward ? 1 : 0);
1986 1986
    }
1987 1987
    int id(const Edge &e) const { return _digraph->id(e); }
1988 1988

	
1989 1989
    int maxNodeId() const { return _digraph->maxNodeId(); }
1990 1990
    int maxArcId() const { return (_digraph->maxArcId() << 1) | 1; }
1991 1991
    int maxEdgeId() const { return _digraph->maxArcId(); }
1992 1992

	
1993 1993
    Node addNode() { return _digraph->addNode(); }
1994 1994
    Edge addEdge(const Node& u, const Node& v) {
1995 1995
      return _digraph->addArc(u, v);
1996 1996
    }
1997 1997

	
1998 1998
    void erase(const Node& i) { _digraph->erase(i); }
1999 1999
    void erase(const Edge& i) { _digraph->erase(i); }
2000 2000

	
2001 2001
    void clear() { _digraph->clear(); }
2002 2002

	
2003 2003
    typedef NodeNumTagIndicator<Digraph> NodeNumTag;
2004 2004
    int nodeNum() const { return _digraph->nodeNum(); }
2005 2005

	
2006 2006
    typedef ArcNumTagIndicator<Digraph> ArcNumTag;
2007 2007
    int arcNum() const { return 2 * _digraph->arcNum(); }
2008 2008

	
2009 2009
    typedef ArcNumTag EdgeNumTag;
2010 2010
    int edgeNum() const { return _digraph->arcNum(); }
2011 2011

	
2012 2012
    typedef FindArcTagIndicator<Digraph> FindArcTag;
2013 2013
    Arc findArc(Node s, Node t, Arc p = INVALID) const {
2014 2014
      if (p == INVALID) {
2015 2015
        Edge arc = _digraph->findArc(s, t);
2016 2016
        if (arc != INVALID) return direct(arc, true);
2017 2017
        arc = _digraph->findArc(t, s);
2018 2018
        if (arc != INVALID) return direct(arc, false);
2019 2019
      } else if (direction(p)) {
2020 2020
        Edge arc = _digraph->findArc(s, t, p);
2021 2021
        if (arc != INVALID) return direct(arc, true);
2022 2022
        arc = _digraph->findArc(t, s);
2023 2023
        if (arc != INVALID) return direct(arc, false);
2024 2024
      } else {
2025 2025
        Edge arc = _digraph->findArc(t, s, p);
2026 2026
        if (arc != INVALID) return direct(arc, false);
2027 2027
      }
2028 2028
      return INVALID;
2029 2029
    }
2030 2030

	
2031 2031
    typedef FindArcTag FindEdgeTag;
2032 2032
    Edge findEdge(Node s, Node t, Edge p = INVALID) const {
2033 2033
      if (s != t) {
2034 2034
        if (p == INVALID) {
2035 2035
          Edge arc = _digraph->findArc(s, t);
2036 2036
          if (arc != INVALID) return arc;
2037 2037
          arc = _digraph->findArc(t, s);
2038 2038
          if (arc != INVALID) return arc;
2039 2039
        } else if (_digraph->source(p) == s) {
2040 2040
          Edge arc = _digraph->findArc(s, t, p);
2041 2041
          if (arc != INVALID) return arc;
2042 2042
          arc = _digraph->findArc(t, s);
2043 2043
          if (arc != INVALID) return arc;
2044 2044
        } else {
2045 2045
          Edge arc = _digraph->findArc(t, s, p);
2046 2046
          if (arc != INVALID) return arc;
2047 2047
        }
2048 2048
      } else {
2049 2049
        return _digraph->findArc(s, t, p);
2050 2050
      }
2051 2051
      return INVALID;
2052 2052
    }
2053 2053

	
2054 2054
  private:
2055 2055

	
2056 2056
    template <typename V>
2057 2057
    class ArcMapBase {
2058 2058
    private:
2059 2059

	
2060 2060
      typedef typename DGR::template ArcMap<V> MapImpl;
2061 2061

	
2062 2062
    public:
2063 2063

	
2064 2064
      typedef typename MapTraits<MapImpl>::ReferenceMapTag ReferenceMapTag;
2065 2065

	
2066 2066
      typedef V Value;
2067 2067
      typedef Arc Key;
2068 2068
      typedef typename MapTraits<MapImpl>::ConstReturnValue ConstReturnValue;
2069 2069
      typedef typename MapTraits<MapImpl>::ReturnValue ReturnValue;
2070 2070
      typedef typename MapTraits<MapImpl>::ConstReturnValue ConstReference;
2071 2071
      typedef typename MapTraits<MapImpl>::ReturnValue Reference;
2072 2072

	
2073 2073
      ArcMapBase(const UndirectorBase<DGR>& adaptor) :
2074 2074
        _forward(*adaptor._digraph), _backward(*adaptor._digraph) {}
2075 2075

	
2076 2076
      ArcMapBase(const UndirectorBase<DGR>& adaptor, const V& value)
2077 2077
        : _forward(*adaptor._digraph, value), 
2078 2078
          _backward(*adaptor._digraph, value) {}
2079 2079

	
2080 2080
      void set(const Arc& a, const V& value) {
2081 2081
        if (direction(a)) {
2082 2082
          _forward.set(a, value);
2083 2083
        } else {
2084 2084
          _backward.set(a, value);
2085 2085
        }
2086 2086
      }
2087 2087

	
2088 2088
      ConstReturnValue operator[](const Arc& a) const {
2089 2089
        if (direction(a)) {
2090 2090
          return _forward[a];
2091 2091
        } else {
2092 2092
          return _backward[a];
2093 2093
        }
2094 2094
      }
2095 2095

	
2096 2096
      ReturnValue operator[](const Arc& a) {
2097 2097
        if (direction(a)) {
2098 2098
          return _forward[a];
2099 2099
        } else {
2100 2100
          return _backward[a];
2101 2101
        }
2102 2102
      }
2103 2103

	
2104 2104
    protected:
2105 2105

	
2106 2106
      MapImpl _forward, _backward;
2107 2107

	
2108 2108
    };
2109 2109

	
2110 2110
  public:
2111 2111

	
2112 2112
    template <typename V>
2113 2113
    class NodeMap : public DGR::template NodeMap<V> {
2114 2114
    public:
2115 2115

	
2116 2116
      typedef V Value;
2117 2117
      typedef typename DGR::template NodeMap<Value> Parent;
2118 2118

	
2119 2119
      explicit NodeMap(const UndirectorBase<DGR>& adaptor)
2120 2120
        : Parent(*adaptor._digraph) {}
2121 2121

	
2122 2122
      NodeMap(const UndirectorBase<DGR>& adaptor, const V& value)
2123 2123
        : Parent(*adaptor._digraph, value) { }
2124 2124

	
2125 2125
    private:
2126 2126
      NodeMap& operator=(const NodeMap& cmap) {
2127 2127
        return operator=<NodeMap>(cmap);
2128 2128
      }
2129 2129

	
2130 2130
      template <typename CMap>
2131 2131
      NodeMap& operator=(const CMap& cmap) {
2132 2132
        Parent::operator=(cmap);
2133 2133
        return *this;
2134 2134
      }
2135 2135

	
2136 2136
    };
2137 2137

	
2138 2138
    template <typename V>
2139 2139
    class ArcMap
2140 2140
      : public SubMapExtender<UndirectorBase<DGR>, ArcMapBase<V> >
2141 2141
    {
2142 2142
    public:
2143 2143
      typedef V Value;
2144 2144
      typedef SubMapExtender<Adaptor, ArcMapBase<V> > Parent;
2145 2145

	
2146 2146
      explicit ArcMap(const UndirectorBase<DGR>& adaptor)
2147 2147
        : Parent(adaptor) {}
2148 2148

	
2149 2149
      ArcMap(const UndirectorBase<DGR>& adaptor, const V& value)
2150 2150
        : Parent(adaptor, value) {}
2151 2151

	
2152 2152
    private:
2153 2153
      ArcMap& operator=(const ArcMap& cmap) {
2154 2154
        return operator=<ArcMap>(cmap);
2155 2155
      }
2156 2156

	
2157 2157
      template <typename CMap>
2158 2158
      ArcMap& operator=(const CMap& cmap) {
2159 2159
        Parent::operator=(cmap);
2160 2160
        return *this;
2161 2161
      }
2162 2162
    };
2163 2163

	
2164 2164
    template <typename V>
2165 2165
    class EdgeMap : public Digraph::template ArcMap<V> {
2166 2166
    public:
2167 2167

	
2168 2168
      typedef V Value;
2169 2169
      typedef typename Digraph::template ArcMap<V> Parent;
2170 2170

	
2171 2171
      explicit EdgeMap(const UndirectorBase<DGR>& adaptor)
2172 2172
        : Parent(*adaptor._digraph) {}
2173 2173

	
2174 2174
      EdgeMap(const UndirectorBase<DGR>& adaptor, const V& value)
2175 2175
        : Parent(*adaptor._digraph, value) {}
2176 2176

	
2177 2177
    private:
2178 2178
      EdgeMap& operator=(const EdgeMap& cmap) {
2179 2179
        return operator=<EdgeMap>(cmap);
2180 2180
      }
2181 2181

	
2182 2182
      template <typename CMap>
2183 2183
      EdgeMap& operator=(const CMap& cmap) {
2184 2184
        Parent::operator=(cmap);
2185 2185
        return *this;
2186 2186
      }
2187 2187

	
2188 2188
    };
2189 2189

	
2190 2190
    typedef typename ItemSetTraits<DGR, Node>::ItemNotifier NodeNotifier;
2191 2191
    NodeNotifier& notifier(Node) const { return _digraph->notifier(Node()); }
2192 2192

	
2193 2193
    typedef typename ItemSetTraits<DGR, Edge>::ItemNotifier EdgeNotifier;
2194 2194
    EdgeNotifier& notifier(Edge) const { return _digraph->notifier(Edge()); }
2195
    
2196
    typedef EdgeNotifier ArcNotifier;
2197
    ArcNotifier& notifier(Arc) const { return _digraph->notifier(Edge()); }
2195 2198

	
2196 2199
  protected:
2197 2200

	
2198 2201
    UndirectorBase() : _digraph(0) {}
2199 2202

	
2200 2203
    DGR* _digraph;
2201 2204

	
2202 2205
    void initialize(DGR& digraph) {
2203 2206
      _digraph = &digraph;
2204 2207
    }
2205 2208

	
2206 2209
  };
2207 2210

	
2208 2211
  /// \ingroup graph_adaptors
2209 2212
  ///
2210 2213
  /// \brief Adaptor class for viewing a digraph as an undirected graph.
2211 2214
  ///
2212 2215
  /// Undirector adaptor can be used for viewing a digraph as an undirected
2213 2216
  /// graph. All arcs of the underlying digraph are showed in the
2214 2217
  /// adaptor as an edge (and also as a pair of arcs, of course).
2215 2218
  /// This adaptor conforms to the \ref concepts::Graph "Graph" concept.
2216 2219
  ///
2217 2220
  /// The adapted digraph can also be modified through this adaptor
2218 2221
  /// by adding or removing nodes or edges, unless the \c GR template
2219 2222
  /// parameter is set to be \c const.
2220 2223
  ///
2221 2224
  /// \tparam DGR The type of the adapted digraph.
2222 2225
  /// It must conform to the \ref concepts::Digraph "Digraph" concept.
2223 2226
  /// It can also be specified to be \c const.
2224 2227
  ///
2225 2228
  /// \note The \c Node type of this adaptor and the adapted digraph are
2226 2229
  /// convertible to each other, moreover the \c Edge type of the adaptor
2227 2230
  /// and the \c Arc type of the adapted digraph are also convertible to
2228 2231
  /// each other.
2229 2232
  /// (Thus the \c Arc type of the adaptor is convertible to the \c Arc type
2230 2233
  /// of the adapted digraph.)
2231 2234
  template<typename DGR>
2232 2235
#ifdef DOXYGEN
2233 2236
  class Undirector {
2234 2237
#else
2235 2238
  class Undirector :
2236 2239
    public GraphAdaptorExtender<UndirectorBase<DGR> > {
2237 2240
#endif
2238 2241
  public:
2239 2242
    /// The type of the adapted digraph.
2240 2243
    typedef DGR Digraph;
2241 2244
    typedef GraphAdaptorExtender<UndirectorBase<DGR> > Parent;
2242 2245
  protected:
2243 2246
    Undirector() { }
2244 2247
  public:
2245 2248

	
2246 2249
    /// \brief Constructor
2247 2250
    ///
2248 2251
    /// Creates an undirected graph from the given digraph.
2249 2252
    Undirector(DGR& digraph) {
2250 2253
      initialize(digraph);
2251 2254
    }
2252 2255

	
2253 2256
    /// \brief Arc map combined from two original arc maps
2254 2257
    ///
2255 2258
    /// This map adaptor class adapts two arc maps of the underlying
2256 2259
    /// digraph to get an arc map of the undirected graph.
2257 2260
    /// Its value type is inherited from the first arc map type (\c FW).
2258 2261
    /// \tparam FW The type of the "foward" arc map.
2259 2262
    /// \tparam BK The type of the "backward" arc map.
2260 2263
    template <typename FW, typename BK>
2261 2264
    class CombinedArcMap {
2262 2265
    public:
2263 2266

	
2264 2267
      /// The key type of the map
2265 2268
      typedef typename Parent::Arc Key;
2266 2269
      /// The value type of the map
2267 2270
      typedef typename FW::Value Value;
2268 2271

	
2269 2272
      typedef typename MapTraits<FW>::ReferenceMapTag ReferenceMapTag;
2270 2273

	
2271 2274
      typedef typename MapTraits<FW>::ReturnValue ReturnValue;
2272 2275
      typedef typename MapTraits<FW>::ConstReturnValue ConstReturnValue;
2273 2276
      typedef typename MapTraits<FW>::ReturnValue Reference;
2274 2277
      typedef typename MapTraits<FW>::ConstReturnValue ConstReference;
2275 2278

	
2276 2279
      /// Constructor
2277 2280
      CombinedArcMap(FW& forward, BK& backward)
2278 2281
        : _forward(&forward), _backward(&backward) {}
2279 2282

	
2280 2283
      /// Sets the value associated with the given key.
2281 2284
      void set(const Key& e, const Value& a) {
2282 2285
        if (Parent::direction(e)) {
2283 2286
          _forward->set(e, a);
2284 2287
        } else {
2285 2288
          _backward->set(e, a);
2286 2289
        }
2287 2290
      }
2288 2291

	
2289 2292
      /// Returns the value associated with the given key.
2290 2293
      ConstReturnValue operator[](const Key& e) const {
2291 2294
        if (Parent::direction(e)) {
2292 2295
          return (*_forward)[e];
2293 2296
        } else {
2294 2297
          return (*_backward)[e];
2295 2298
        }
2296 2299
      }
2297 2300

	
2298 2301
      /// Returns a reference to the value associated with the given key.
2299 2302
      ReturnValue operator[](const Key& e) {
2300 2303
        if (Parent::direction(e)) {
2301 2304
          return (*_forward)[e];
2302 2305
        } else {
2303 2306
          return (*_backward)[e];
2304 2307
        }
2305 2308
      }
2306 2309

	
2307 2310
    protected:
2308 2311

	
2309 2312
      FW* _forward;
2310 2313
      BK* _backward;
2311 2314

	
2312 2315
    };
2313 2316

	
2314 2317
    /// \brief Returns a combined arc map
2315 2318
    ///
2316 2319
    /// This function just returns a combined arc map.
2317 2320
    template <typename FW, typename BK>
2318 2321
    static CombinedArcMap<FW, BK>
2319 2322
    combinedArcMap(FW& forward, BK& backward) {
2320 2323
      return CombinedArcMap<FW, BK>(forward, backward);
2321 2324
    }
2322 2325

	
2323 2326
    template <typename FW, typename BK>
2324 2327
    static CombinedArcMap<const FW, BK>
2325 2328
    combinedArcMap(const FW& forward, BK& backward) {
2326 2329
      return CombinedArcMap<const FW, BK>(forward, backward);
2327 2330
    }
2328 2331

	
2329 2332
    template <typename FW, typename BK>
2330 2333
    static CombinedArcMap<FW, const BK>
2331 2334
    combinedArcMap(FW& forward, const BK& backward) {
2332 2335
      return CombinedArcMap<FW, const BK>(forward, backward);
2333 2336
    }
2334 2337

	
2335 2338
    template <typename FW, typename BK>
2336 2339
    static CombinedArcMap<const FW, const BK>
2337 2340
    combinedArcMap(const FW& forward, const BK& backward) {
2338 2341
      return CombinedArcMap<const FW, const BK>(forward, backward);
2339 2342
    }
2340 2343

	
2341 2344
  };
2342 2345

	
2343 2346
  /// \brief Returns a read-only Undirector adaptor
2344 2347
  ///
2345 2348
  /// This function just returns a read-only \ref Undirector adaptor.
2346 2349
  /// \ingroup graph_adaptors
2347 2350
  /// \relates Undirector
2348 2351
  template<typename DGR>
2349 2352
  Undirector<const DGR> undirector(const DGR& digraph) {
2350 2353
    return Undirector<const DGR>(digraph);
2351 2354
  }
2352 2355

	
2353 2356

	
2354 2357
  template <typename GR, typename DM>
2355 2358
  class OrienterBase {
2356 2359
  public:
2357 2360

	
2358 2361
    typedef GR Graph;
2359 2362
    typedef DM DirectionMap;
2360 2363

	
2361 2364
    typedef typename GR::Node Node;
2362 2365
    typedef typename GR::Edge Arc;
2363 2366

	
2364 2367
    void reverseArc(const Arc& arc) {
2365 2368
      _direction->set(arc, !(*_direction)[arc]);
2366 2369
    }
2367 2370

	
2368 2371
    void first(Node& i) const { _graph->first(i); }
2369 2372
    void first(Arc& i) const { _graph->first(i); }
2370 2373
    void firstIn(Arc& i, const Node& n) const {
2371 2374
      bool d = true;
2372 2375
      _graph->firstInc(i, d, n);
2373 2376
      while (i != INVALID && d == (*_direction)[i]) _graph->nextInc(i, d);
2374 2377
    }
2375 2378
    void firstOut(Arc& i, const Node& n ) const {
2376 2379
      bool d = true;
2377 2380
      _graph->firstInc(i, d, n);
2378 2381
      while (i != INVALID && d != (*_direction)[i]) _graph->nextInc(i, d);
2379 2382
    }
2380 2383

	
2381 2384
    void next(Node& i) const { _graph->next(i); }
2382 2385
    void next(Arc& i) const { _graph->next(i); }
2383 2386
    void nextIn(Arc& i) const {
2384 2387
      bool d = !(*_direction)[i];
2385 2388
      _graph->nextInc(i, d);
2386 2389
      while (i != INVALID && d == (*_direction)[i]) _graph->nextInc(i, d);
2387 2390
    }
2388 2391
    void nextOut(Arc& i) const {
2389 2392
      bool d = (*_direction)[i];
2390 2393
      _graph->nextInc(i, d);
2391 2394
      while (i != INVALID && d != (*_direction)[i]) _graph->nextInc(i, d);
2392 2395
    }
2393 2396

	
2394 2397
    Node source(const Arc& e) const {
2395 2398
      return (*_direction)[e] ? _graph->u(e) : _graph->v(e);
2396 2399
    }
2397 2400
    Node target(const Arc& e) const {
2398 2401
      return (*_direction)[e] ? _graph->v(e) : _graph->u(e);
2399 2402
    }
2400 2403

	
2401 2404
    typedef NodeNumTagIndicator<Graph> NodeNumTag;
2402 2405
    int nodeNum() const { return _graph->nodeNum(); }
2403 2406

	
2404 2407
    typedef EdgeNumTagIndicator<Graph> ArcNumTag;
2405 2408
    int arcNum() const { return _graph->edgeNum(); }
2406 2409

	
2407 2410
    typedef FindEdgeTagIndicator<Graph> FindArcTag;
2408 2411
    Arc findArc(const Node& u, const Node& v,
2409 2412
                const Arc& prev = INVALID) const {
2410 2413
      Arc arc = _graph->findEdge(u, v, prev);
2411 2414
      while (arc != INVALID && source(arc) != u) {
2412 2415
        arc = _graph->findEdge(u, v, arc);
2413 2416
      }
2414 2417
      return arc;
2415 2418
    }
2416 2419

	
2417 2420
    Node addNode() {
2418 2421
      return Node(_graph->addNode());
2419 2422
    }
2420 2423

	
2421 2424
    Arc addArc(const Node& u, const Node& v) {
2422 2425
      Arc arc = _graph->addEdge(u, v);
2423 2426
      _direction->set(arc, _graph->u(arc) == u);
2424 2427
      return arc;
2425 2428
    }
2426 2429

	
2427 2430
    void erase(const Node& i) { _graph->erase(i); }
2428 2431
    void erase(const Arc& i) { _graph->erase(i); }
2429 2432

	
2430 2433
    void clear() { _graph->clear(); }
2431 2434

	
2432 2435
    int id(const Node& v) const { return _graph->id(v); }
2433 2436
    int id(const Arc& e) const { return _graph->id(e); }
2434 2437

	
2435 2438
    Node nodeFromId(int idx) const { return _graph->nodeFromId(idx); }
2436 2439
    Arc arcFromId(int idx) const { return _graph->edgeFromId(idx); }
2437 2440

	
2438 2441
    int maxNodeId() const { return _graph->maxNodeId(); }
2439 2442
    int maxArcId() const { return _graph->maxEdgeId(); }
2440 2443

	
2441 2444
    typedef typename ItemSetTraits<GR, Node>::ItemNotifier NodeNotifier;
2442 2445
    NodeNotifier& notifier(Node) const { return _graph->notifier(Node()); }
2443 2446

	
2444 2447
    typedef typename ItemSetTraits<GR, Arc>::ItemNotifier ArcNotifier;
2445 2448
    ArcNotifier& notifier(Arc) const { return _graph->notifier(Arc()); }
2446 2449

	
2447 2450
    template <typename V>
2448 2451
    class NodeMap : public GR::template NodeMap<V> {
2449 2452
    public:
2450 2453

	
2451 2454
      typedef typename GR::template NodeMap<V> Parent;
2452 2455

	
2453 2456
      explicit NodeMap(const OrienterBase<GR, DM>& adapter)
2454 2457
        : Parent(*adapter._graph) {}
2455 2458

	
2456 2459
      NodeMap(const OrienterBase<GR, DM>& adapter, const V& value)
2457 2460
        : Parent(*adapter._graph, value) {}
2458 2461

	
2459 2462
    private:
2460 2463
      NodeMap& operator=(const NodeMap& cmap) {
2461 2464
        return operator=<NodeMap>(cmap);
2462 2465
      }
2463 2466

	
2464 2467
      template <typename CMap>
2465 2468
      NodeMap& operator=(const CMap& cmap) {
2466 2469
        Parent::operator=(cmap);
2467 2470
        return *this;
2468 2471
      }
2469 2472

	
2470 2473
    };
2471 2474

	
2472 2475
    template <typename V>
2473 2476
    class ArcMap : public GR::template EdgeMap<V> {
2474 2477
    public:
2475 2478

	
2476 2479
      typedef typename Graph::template EdgeMap<V> Parent;
2477 2480

	
2478 2481
      explicit ArcMap(const OrienterBase<GR, DM>& adapter)
2479 2482
        : Parent(*adapter._graph) { }
2480 2483

	
2481 2484
      ArcMap(const OrienterBase<GR, DM>& adapter, const V& value)
2482 2485
        : Parent(*adapter._graph, value) { }
2483 2486

	
2484 2487
    private:
2485 2488
      ArcMap& operator=(const ArcMap& cmap) {
2486 2489
        return operator=<ArcMap>(cmap);
2487 2490
      }
2488 2491

	
2489 2492
      template <typename CMap>
2490 2493
      ArcMap& operator=(const CMap& cmap) {
2491 2494
        Parent::operator=(cmap);
2492 2495
        return *this;
2493 2496
      }
2494 2497
    };
2495 2498

	
2496 2499

	
2497 2500

	
2498 2501
  protected:
2499 2502
    Graph* _graph;
2500 2503
    DM* _direction;
2501 2504

	
2502 2505
    void initialize(GR& graph, DM& direction) {
2503 2506
      _graph = &graph;
2504 2507
      _direction = &direction;
2505 2508
    }
2506 2509

	
2507 2510
  };
2508 2511

	
2509 2512
  /// \ingroup graph_adaptors
2510 2513
  ///
2511 2514
  /// \brief Adaptor class for orienting the edges of a graph to get a digraph
2512 2515
  ///
2513 2516
  /// Orienter adaptor can be used for orienting the edges of a graph to
2514 2517
  /// get a digraph. A \c bool edge map of the underlying graph must be
2515 2518
  /// specified, which define the direction of the arcs in the adaptor.
2516 2519
  /// The arcs can be easily reversed by the \c reverseArc() member function
2517 2520
  /// of the adaptor.
2518 2521
  /// This class conforms to the \ref concepts::Digraph "Digraph" concept.
2519 2522
  ///
2520 2523
  /// The adapted graph can also be modified through this adaptor
2521 2524
  /// by adding or removing nodes or arcs, unless the \c GR template
2522 2525
  /// parameter is set to be \c const.
2523 2526
  ///
2524 2527
  /// \tparam GR The type of the adapted graph.
2525 2528
  /// It must conform to the \ref concepts::Graph "Graph" concept.
2526 2529
  /// It can also be specified to be \c const.
2527 2530
  /// \tparam DM The type of the direction map.
2528 2531
  /// It must be a \c bool (or convertible) edge map of the
2529 2532
  /// adapted graph. The default type is
2530 2533
  /// \ref concepts::Graph::EdgeMap "GR::EdgeMap<bool>".
2531 2534
  ///
2532 2535
  /// \note The \c Node type of this adaptor and the adapted graph are
2533 2536
  /// convertible to each other, moreover the \c Arc type of the adaptor
2534 2537
  /// and the \c Edge type of the adapted graph are also convertible to
2535 2538
  /// each other.
2536 2539
#ifdef DOXYGEN
2537 2540
  template<typename GR,
2538 2541
           typename DM>
2539 2542
  class Orienter {
2540 2543
#else
2541 2544
  template<typename GR,
2542 2545
           typename DM = typename GR::template EdgeMap<bool> >
2543 2546
  class Orienter :
2544 2547
    public DigraphAdaptorExtender<OrienterBase<GR, DM> > {
2545 2548
#endif
2546 2549
  public:
2547 2550

	
2548 2551
    /// The type of the adapted graph.
2549 2552
    typedef GR Graph;
2550 2553
    /// The type of the direction edge map.
2551 2554
    typedef DM DirectionMap;
2552 2555

	
2553 2556
    typedef DigraphAdaptorExtender<OrienterBase<GR, DM> > Parent;
2554 2557
    typedef typename Parent::Arc Arc;
2555 2558
  protected:
2556 2559
    Orienter() { }
2557 2560
  public:
2558 2561

	
2559 2562
    /// \brief Constructor
2560 2563
    ///
2561 2564
    /// Constructor of the adaptor.
2562 2565
    Orienter(GR& graph, DM& direction) {
2563 2566
      Parent::initialize(graph, direction);
2564 2567
    }
2565 2568

	
2566 2569
    /// \brief Reverses the given arc
2567 2570
    ///
2568 2571
    /// This function reverses the given arc.
2569 2572
    /// It is done by simply negate the assigned value of \c a
2570 2573
    /// in the direction map.
2571 2574
    void reverseArc(const Arc& a) {
2572 2575
      Parent::reverseArc(a);
2573 2576
    }
2574 2577
  };
2575 2578

	
2576 2579
  /// \brief Returns a read-only Orienter adaptor
2577 2580
  ///
2578 2581
  /// This function just returns a read-only \ref Orienter adaptor.
2579 2582
  /// \ingroup graph_adaptors
2580 2583
  /// \relates Orienter
2581 2584
  template<typename GR, typename DM>
2582 2585
  Orienter<const GR, DM>
2583 2586
  orienter(const GR& graph, DM& direction) {
2584 2587
    return Orienter<const GR, DM>(graph, direction);
2585 2588
  }
2586 2589

	
2587 2590
  template<typename GR, typename DM>
2588 2591
  Orienter<const GR, const DM>
2589 2592
  orienter(const GR& graph, const DM& direction) {
2590 2593
    return Orienter<const GR, const DM>(graph, direction);
2591 2594
  }
2592 2595

	
2593 2596
  namespace _adaptor_bits {
2594 2597

	
2595 2598
    template <typename DGR, typename CM, typename FM, typename TL>
2596 2599
    class ResForwardFilter {
2597 2600
    public:
2598 2601

	
2599 2602
      typedef typename DGR::Arc Key;
2600 2603
      typedef bool Value;
2601 2604

	
2602 2605
    private:
2603 2606

	
2604 2607
      const CM* _capacity;
2605 2608
      const FM* _flow;
2606 2609
      TL _tolerance;
2607 2610

	
2608 2611
    public:
2609 2612

	
2610 2613
      ResForwardFilter(const CM& capacity, const FM& flow,
2611 2614
                       const TL& tolerance = TL())
2612 2615
        : _capacity(&capacity), _flow(&flow), _tolerance(tolerance) { }
2613 2616

	
2614 2617
      bool operator[](const typename DGR::Arc& a) const {
2615 2618
        return _tolerance.positive((*_capacity)[a] - (*_flow)[a]);
2616 2619
      }
2617 2620
    };
2618 2621

	
2619 2622
    template<typename DGR,typename CM, typename FM, typename TL>
2620 2623
    class ResBackwardFilter {
2621 2624
    public:
2622 2625

	
2623 2626
      typedef typename DGR::Arc Key;
2624 2627
      typedef bool Value;
2625 2628

	
2626 2629
    private:
2627 2630

	
2628 2631
      const CM* _capacity;
2629 2632
      const FM* _flow;
2630 2633
      TL _tolerance;
2631 2634

	
2632 2635
    public:
2633 2636

	
2634 2637
      ResBackwardFilter(const CM& capacity, const FM& flow,
2635 2638
                        const TL& tolerance = TL())
2636 2639
        : _capacity(&capacity), _flow(&flow), _tolerance(tolerance) { }
2637 2640

	
2638 2641
      bool operator[](const typename DGR::Arc& a) const {
2639 2642
        return _tolerance.positive((*_flow)[a]);
2640 2643
      }
2641 2644
    };
2642 2645

	
2643 2646
  }
2644 2647

	
2645 2648
  /// \ingroup graph_adaptors
2646 2649
  ///
2647 2650
  /// \brief Adaptor class for composing the residual digraph for directed
2648 2651
  /// flow and circulation problems.
2649 2652
  ///
2650 2653
  /// ResidualDigraph can be used for composing the \e residual digraph
2651 2654
  /// for directed flow and circulation problems. Let \f$ G=(V, A) \f$
2652 2655
  /// be a directed graph and let \f$ F \f$ be a number type.
2653 2656
  /// Let \f$ flow, cap: A\to F \f$ be functions on the arcs.
2654 2657
  /// This adaptor implements a digraph structure with node set \f$ V \f$
2655 2658
  /// and arc set \f$ A_{forward}\cup A_{backward} \f$,
2656 2659
  /// where \f$ A_{forward}=\{uv : uv\in A, flow(uv)<cap(uv)\} \f$ and
2657 2660
  /// \f$ A_{backward}=\{vu : uv\in A, flow(uv)>0\} \f$, i.e. the so
2658 2661
  /// called residual digraph.
2659 2662
  /// When the union \f$ A_{forward}\cup A_{backward} \f$ is taken,
2660 2663
  /// multiplicities are counted, i.e. the adaptor has exactly
2661 2664
  /// \f$ |A_{forward}| + |A_{backward}|\f$ arcs (it may have parallel
2662 2665
  /// arcs).
2663 2666
  /// This class conforms to the \ref concepts::Digraph "Digraph" concept.
2664 2667
  ///
2665 2668
  /// \tparam DGR The type of the adapted digraph.
2666 2669
  /// It must conform to the \ref concepts::Digraph "Digraph" concept.
2667 2670
  /// It is implicitly \c const.
2668 2671
  /// \tparam CM The type of the capacity map.
2669 2672
  /// It must be an arc map of some numerical type, which defines
2670 2673
  /// the capacities in the flow problem. It is implicitly \c const.
2671 2674
  /// The default type is
2672 2675
  /// \ref concepts::Digraph::ArcMap "GR::ArcMap<int>".
2673 2676
  /// \tparam FM The type of the flow map.
2674 2677
  /// It must be an arc map of some numerical type, which defines
2675 2678
  /// the flow values in the flow problem. The default type is \c CM.
2676 2679
  /// \tparam TL The tolerance type for handling inexact computation.
2677 2680
  /// The default tolerance type depends on the value type of the
2678 2681
  /// capacity map.
2679 2682
  ///
2680 2683
  /// \note This adaptor is implemented using Undirector and FilterArcs
2681 2684
  /// adaptors.
2682 2685
  ///
2683 2686
  /// \note The \c Node type of this adaptor and the adapted digraph are
2684 2687
  /// convertible to each other, moreover the \c Arc type of the adaptor
2685 2688
  /// is convertible to the \c Arc type of the adapted digraph.
2686 2689
#ifdef DOXYGEN
2687 2690
  template<typename DGR, typename CM, typename FM, typename TL>
2688 2691
  class ResidualDigraph
2689 2692
#else
2690 2693
  template<typename DGR,
2691 2694
           typename CM = typename DGR::template ArcMap<int>,
2692 2695
           typename FM = CM,
2693 2696
           typename TL = Tolerance<typename CM::Value> >
2694 2697
  class ResidualDigraph 
2695 2698
    : public SubDigraph<
2696 2699
        Undirector<const DGR>,
2697 2700
        ConstMap<typename DGR::Node, Const<bool, true> >,
2698 2701
        typename Undirector<const DGR>::template CombinedArcMap<
2699 2702
          _adaptor_bits::ResForwardFilter<const DGR, CM, FM, TL>,
2700 2703
          _adaptor_bits::ResBackwardFilter<const DGR, CM, FM, TL> > >
2701 2704
#endif
2702 2705
  {
2703 2706
  public:
2704 2707

	
2705 2708
    /// The type of the underlying digraph.
2706 2709
    typedef DGR Digraph;
2707 2710
    /// The type of the capacity map.
2708 2711
    typedef CM CapacityMap;
2709 2712
    /// The type of the flow map.
2710 2713
    typedef FM FlowMap;
2711 2714
    /// The tolerance type.
2712 2715
    typedef TL Tolerance;
2713 2716

	
2714 2717
    typedef typename CapacityMap::Value Value;
2715 2718
    typedef ResidualDigraph Adaptor;
2716 2719

	
2717 2720
  protected:
2718 2721

	
2719 2722
    typedef Undirector<const Digraph> Undirected;
2720 2723

	
2721 2724
    typedef ConstMap<typename DGR::Node, Const<bool, true> > NodeFilter;
2722 2725

	
2723 2726
    typedef _adaptor_bits::ResForwardFilter<const DGR, CM,
2724 2727
                                            FM, TL> ForwardFilter;
2725 2728

	
2726 2729
    typedef _adaptor_bits::ResBackwardFilter<const DGR, CM,
2727 2730
                                             FM, TL> BackwardFilter;
2728 2731

	
2729 2732
    typedef typename Undirected::
2730 2733
      template CombinedArcMap<ForwardFilter, BackwardFilter> ArcFilter;
2731 2734

	
2732 2735
    typedef SubDigraph<Undirected, NodeFilter, ArcFilter> Parent;
2733 2736

	
2734 2737
    const CapacityMap* _capacity;
2735 2738
    FlowMap* _flow;
2736 2739

	
2737 2740
    Undirected _graph;
2738 2741
    NodeFilter _node_filter;
2739 2742
    ForwardFilter _forward_filter;
2740 2743
    BackwardFilter _backward_filter;
2741 2744
    ArcFilter _arc_filter;
2742 2745

	
2743 2746
  public:
2744 2747

	
2745 2748
    /// \brief Constructor
2746 2749
    ///
2747 2750
    /// Constructor of the residual digraph adaptor. The parameters are the
2748 2751
    /// digraph, the capacity map, the flow map, and a tolerance object.
2749 2752
    ResidualDigraph(const DGR& digraph, const CM& capacity,
2750 2753
                    FM& flow, const TL& tolerance = Tolerance())
2751 2754
      : Parent(), _capacity(&capacity), _flow(&flow), 
2752 2755
        _graph(digraph), _node_filter(),
2753 2756
        _forward_filter(capacity, flow, tolerance),
2754 2757
        _backward_filter(capacity, flow, tolerance),
2755 2758
        _arc_filter(_forward_filter, _backward_filter)
2756 2759
    {
2757 2760
      Parent::initialize(_graph, _node_filter, _arc_filter);
2758 2761
    }
2759 2762

	
2760 2763
    typedef typename Parent::Arc Arc;
2761 2764

	
2762 2765
    /// \brief Returns the residual capacity of the given arc.
2763 2766
    ///
2764 2767
    /// Returns the residual capacity of the given arc.
2765 2768
    Value residualCapacity(const Arc& a) const {
2766 2769
      if (Undirected::direction(a)) {
2767 2770
        return (*_capacity)[a] - (*_flow)[a];
2768 2771
      } else {
2769 2772
        return (*_flow)[a];
2770 2773
      }
2771 2774
    }
2772 2775

	
2773 2776
    /// \brief Augments on the given arc in the residual digraph.
2774 2777
    ///
2775 2778
    /// Augments on the given arc in the residual digraph. It increases
2776 2779
    /// or decreases the flow value on the original arc according to the
2777 2780
    /// direction of the residual arc.
2778 2781
    void augment(const Arc& a, const Value& v) const {
2779 2782
      if (Undirected::direction(a)) {
2780 2783
        _flow->set(a, (*_flow)[a] + v);
2781 2784
      } else {
2782 2785
        _flow->set(a, (*_flow)[a] - v);
2783 2786
      }
2784 2787
    }
2785 2788

	
2786 2789
    /// \brief Returns \c true if the given residual arc is a forward arc.
2787 2790
    ///
2788 2791
    /// Returns \c true if the given residual arc has the same orientation
2789 2792
    /// as the original arc, i.e. it is a so called forward arc.
2790 2793
    static bool forward(const Arc& a) {
2791 2794
      return Undirected::direction(a);
2792 2795
    }
2793 2796

	
2794 2797
    /// \brief Returns \c true if the given residual arc is a backward arc.
2795 2798
    ///
2796 2799
    /// Returns \c true if the given residual arc has the opposite orientation
2797 2800
    /// than the original arc, i.e. it is a so called backward arc.
2798 2801
    static bool backward(const Arc& a) {
2799 2802
      return !Undirected::direction(a);
2800 2803
    }
2801 2804

	
2802 2805
    /// \brief Returns the forward oriented residual arc.
2803 2806
    ///
2804 2807
    /// Returns the forward oriented residual arc related to the given
2805 2808
    /// arc of the underlying digraph.
2806 2809
    static Arc forward(const typename Digraph::Arc& a) {
2807 2810
      return Undirected::direct(a, true);
2808 2811
    }
2809 2812

	
2810 2813
    /// \brief Returns the backward oriented residual arc.
2811 2814
    ///
2812 2815
    /// Returns the backward oriented residual arc related to the given
2813 2816
    /// arc of the underlying digraph.
2814 2817
    static Arc backward(const typename Digraph::Arc& a) {
2815 2818
      return Undirected::direct(a, false);
2816 2819
    }
2817 2820

	
2818 2821
    /// \brief Residual capacity map.
2819 2822
    ///
2820 2823
    /// This map adaptor class can be used for obtaining the residual
2821 2824
    /// capacities as an arc map of the residual digraph.
2822 2825
    /// Its value type is inherited from the capacity map.
2823 2826
    class ResidualCapacity {
2824 2827
    protected:
2825 2828
      const Adaptor* _adaptor;
2826 2829
    public:
2827 2830
      /// The key type of the map
2828 2831
      typedef Arc Key;
2829 2832
      /// The value type of the map
2830 2833
      typedef typename CapacityMap::Value Value;
2831 2834

	
2832 2835
      /// Constructor
2833 2836
      ResidualCapacity(const ResidualDigraph<DGR, CM, FM, TL>& adaptor) 
2834 2837
        : _adaptor(&adaptor) {}
2835 2838

	
2836 2839
      /// Returns the value associated with the given residual arc
2837 2840
      Value operator[](const Arc& a) const {
2838 2841
        return _adaptor->residualCapacity(a);
2839 2842
      }
2840 2843

	
2841 2844
    };
2842 2845

	
2843 2846
    /// \brief Returns a residual capacity map
2844 2847
    ///
2845 2848
    /// This function just returns a residual capacity map.
2846 2849
    ResidualCapacity residualCapacity() const {
2847 2850
      return ResidualCapacity(*this);
2848 2851
    }
2849 2852

	
2850 2853
  };
2851 2854

	
2852 2855
  /// \brief Returns a (read-only) Residual adaptor
2853 2856
  ///
2854 2857
  /// This function just returns a (read-only) \ref ResidualDigraph adaptor.
2855 2858
  /// \ingroup graph_adaptors
2856 2859
  /// \relates ResidualDigraph
2857 2860
    template<typename DGR, typename CM, typename FM>
2858 2861
  ResidualDigraph<DGR, CM, FM>
2859 2862
  residualDigraph(const DGR& digraph, const CM& capacity_map, FM& flow_map) {
2860 2863
    return ResidualDigraph<DGR, CM, FM> (digraph, capacity_map, flow_map);
2861 2864
  }
2862 2865

	
2863 2866

	
2864 2867
  template <typename DGR>
2865 2868
  class SplitNodesBase {
2866 2869
  public:
2867 2870

	
2868 2871
    typedef DGR Digraph;
2869 2872
    typedef DigraphAdaptorBase<const DGR> Parent;
2870 2873
    typedef SplitNodesBase Adaptor;
2871 2874

	
2872 2875
    typedef typename DGR::Node DigraphNode;
2873 2876
    typedef typename DGR::Arc DigraphArc;
2874 2877

	
2875 2878
    class Node;
2876 2879
    class Arc;
2877 2880

	
2878 2881
  private:
2879 2882

	
2880 2883
    template <typename T> class NodeMapBase;
2881 2884
    template <typename T> class ArcMapBase;
2882 2885

	
2883 2886
  public:
2884 2887

	
2885 2888
    class Node : public DigraphNode {
2886 2889
      friend class SplitNodesBase;
2887 2890
      template <typename T> friend class NodeMapBase;
2888 2891
    private:
2889 2892

	
2890 2893
      bool _in;
2891 2894
      Node(DigraphNode node, bool in)
2892 2895
        : DigraphNode(node), _in(in) {}
2893 2896

	
2894 2897
    public:
2895 2898

	
2896 2899
      Node() {}
2897 2900
      Node(Invalid) : DigraphNode(INVALID), _in(true) {}
2898 2901

	
2899 2902
      bool operator==(const Node& node) const {
2900 2903
        return DigraphNode::operator==(node) && _in == node._in;
2901 2904
      }
2902 2905

	
2903 2906
      bool operator!=(const Node& node) const {
2904 2907
        return !(*this == node);
2905 2908
      }
2906 2909

	
2907 2910
      bool operator<(const Node& node) const {
2908 2911
        return DigraphNode::operator<(node) ||
2909 2912
          (DigraphNode::operator==(node) && _in < node._in);
2910 2913
      }
2911 2914
    };
2912 2915

	
2913 2916
    class Arc {
2914 2917
      friend class SplitNodesBase;
2915 2918
      template <typename T> friend class ArcMapBase;
2916 2919
    private:
2917 2920
      typedef BiVariant<DigraphArc, DigraphNode> ArcImpl;
2918 2921

	
2919 2922
      explicit Arc(const DigraphArc& arc) : _item(arc) {}
2920 2923
      explicit Arc(const DigraphNode& node) : _item(node) {}
2921 2924

	
2922 2925
      ArcImpl _item;
2923 2926

	
2924 2927
    public:
2925 2928
      Arc() {}
2926 2929
      Arc(Invalid) : _item(DigraphArc(INVALID)) {}
2927 2930

	
2928 2931
      bool operator==(const Arc& arc) const {
2929 2932
        if (_item.firstState()) {
2930 2933
          if (arc._item.firstState()) {
2931 2934
            return _item.first() == arc._item.first();
2932 2935
          }
2933 2936
        } else {
2934 2937
          if (arc._item.secondState()) {
2935 2938
            return _item.second() == arc._item.second();
2936 2939
          }
2937 2940
        }
2938 2941
        return false;
2939 2942
      }
2940 2943

	
2941 2944
      bool operator!=(const Arc& arc) const {
2942 2945
        return !(*this == arc);
2943 2946
      }
2944 2947

	
2945 2948
      bool operator<(const Arc& arc) const {
2946 2949
        if (_item.firstState()) {
2947 2950
          if (arc._item.firstState()) {
2948 2951
            return _item.first() < arc._item.first();
2949 2952
          }
2950 2953
          return false;
2951 2954
        } else {
2952 2955
          if (arc._item.secondState()) {
2953 2956
            return _item.second() < arc._item.second();
2954 2957
          }
2955 2958
          return true;
2956 2959
        }
2957 2960
      }
2958 2961

	
2959 2962
      operator DigraphArc() const { return _item.first(); }
2960 2963
      operator DigraphNode() const { return _item.second(); }
2961 2964

	
2962 2965
    };
Ignore white space 1536 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5 5
 * Copyright (C) 2003-2009
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
///\ingroup graph_concepts
20 20
///\file
21 21
///\brief The concept of graph components.
22 22

	
23 23
#ifndef LEMON_CONCEPTS_GRAPH_COMPONENTS_H
24 24
#define LEMON_CONCEPTS_GRAPH_COMPONENTS_H
25 25

	
26 26
#include <lemon/core.h>
27 27
#include <lemon/concepts/maps.h>
28 28

	
29 29
#include <lemon/bits/alteration_notifier.h>
30 30

	
31 31
namespace lemon {
32 32
  namespace concepts {
33 33

	
34
    /// \brief Skeleton class for graph Node and Arc types
34
    /// \brief Concept class for \c Node, \c Arc and \c Edge types.
35 35
    ///
36
    /// This class describes the interface of Node and Arc (and Edge
37
    /// in undirected graphs) subtypes of graph types.
36
    /// This class describes the concept of \c Node, \c Arc and \c Edge
37
    /// subtypes of digraph and graph types.
38 38
    ///
39 39
    /// \note This class is a template class so that we can use it to
40
    /// create graph skeleton classes. The reason for this is than Node
41
    /// and Arc types should \em not derive from the same base class.
42
    /// For Node you should instantiate it with character 'n' and for Arc
43
    /// with 'a'.
44

	
40
    /// create graph skeleton classes. The reason for this is that \c Node
41
    /// and \c Arc (or \c Edge) types should \e not derive from the same 
42
    /// base class. For \c Node you should instantiate it with character
43
    /// \c 'n', for \c Arc with \c 'a' and for \c Edge with \c 'e'.
45 44
#ifndef DOXYGEN
46 45
    template <char sel = '0'>
47 46
#endif
48 47
    class GraphItem {
49 48
    public:
50 49
      /// \brief Default constructor.
51 50
      ///
51
      /// Default constructor.
52 52
      /// \warning The default constructor is not required to set
53 53
      /// the item to some well-defined value. So you should consider it
54 54
      /// as uninitialized.
55 55
      GraphItem() {}
56

	
56 57
      /// \brief Copy constructor.
57 58
      ///
58 59
      /// Copy constructor.
60
      GraphItem(const GraphItem &) {}
61

	
62
      /// \brief Constructor for conversion from \c INVALID.
59 63
      ///
60
      GraphItem(const GraphItem &) {}
61
      /// \brief Invalid constructor \& conversion.
62
      ///
63
      /// This constructor initializes the item to be invalid.
64
      /// Constructor for conversion from \c INVALID.
65
      /// It initializes the item to be invalid.
64 66
      /// \sa Invalid for more details.
65 67
      GraphItem(Invalid) {}
66
      /// \brief Assign operator for nodes.
68

	
69
      /// \brief Assignment operator.
67 70
      ///
68
      /// The nodes are assignable.
69
      ///
70
      GraphItem& operator=(GraphItem const&) { return *this; }
71
      /// Assignment operator for the item.
72
      GraphItem& operator=(const GraphItem&) { return *this; }
73

	
71 74
      /// \brief Equality operator.
72 75
      ///
73
      /// Two iterators are equal if and only if they represents the
74
      /// same node in the graph or both are invalid.
75
      bool operator==(GraphItem) const { return false; }
76
      /// Equality operator.
77
      bool operator==(const GraphItem&) const { return false; }
78

	
76 79
      /// \brief Inequality operator.
77 80
      ///
78
      /// \sa operator==(const Node& n)
81
      /// Inequality operator.
82
      bool operator!=(const GraphItem&) const { return false; }
83

	
84
      /// \brief Ordering operator.
79 85
      ///
80
      bool operator!=(GraphItem) const { return false; }
81

	
82
      /// \brief Artificial ordering operator.
83
      ///
84
      /// To allow the use of graph descriptors as key type in std::map or
85
      /// similar associative container we require this.
86
      /// This operator defines an ordering of the items.
87
      /// It makes possible to use graph item types as key types in 
88
      /// associative containers (e.g. \c std::map).
86 89
      ///
87 90
      /// \note This operator only have to define some strict ordering of
88 91
      /// the items; this order has nothing to do with the iteration
89 92
      /// ordering of the items.
90
      bool operator<(GraphItem) const { return false; }
93
      bool operator<(const GraphItem&) const { return false; }
91 94

	
92 95
      template<typename _GraphItem>
93 96
      struct Constraints {
94 97
        void constraints() {
95 98
          _GraphItem i1;
96 99
          _GraphItem i2 = i1;
97 100
          _GraphItem i3 = INVALID;
98 101

	
99 102
          i1 = i2 = i3;
100 103

	
101 104
          bool b;
102
          //          b = (ia == ib) && (ia != ib) && (ia < ib);
103 105
          b = (ia == ib) && (ia != ib);
104 106
          b = (ia == INVALID) && (ib != INVALID);
105 107
          b = (ia < ib);
106 108
        }
107 109

	
108 110
        const _GraphItem &ia;
109 111
        const _GraphItem &ib;
110 112
      };
111 113
    };
112 114

	
113
    /// \brief An empty base directed graph class.
115
    /// \brief Base skeleton class for directed graphs.
114 116
    ///
115
    /// This class provides the minimal set of features needed for a
116
    /// directed graph structure. All digraph concepts have to
117
    /// conform to this base directed graph. It just provides types
118
    /// for nodes and arcs and functions to get the source and the
119
    /// target of the arcs.
117
    /// This class describes the base interface of directed graph types.
118
    /// All digraph %concepts have to conform to this class.
119
    /// It just provides types for nodes and arcs and functions 
120
    /// to get the source and the target nodes of arcs.
120 121
    class BaseDigraphComponent {
121 122
    public:
122 123

	
123 124
      typedef BaseDigraphComponent Digraph;
124 125

	
125 126
      /// \brief Node class of the digraph.
126 127
      ///
127
      /// This class represents the Nodes of the digraph.
128
      ///
128
      /// This class represents the nodes of the digraph.
129 129
      typedef GraphItem<'n'> Node;
130 130

	
131 131
      /// \brief Arc class of the digraph.
132 132
      ///
133
      /// This class represents the Arcs of the digraph.
133
      /// This class represents the arcs of the digraph.
134
      typedef GraphItem<'a'> Arc;
135

	
136
      /// \brief Return the source node of an arc.
134 137
      ///
135
      typedef GraphItem<'e'> Arc;
138
      /// This function returns the source node of an arc.
139
      Node source(const Arc&) const { return INVALID; }
136 140

	
137
      /// \brief Gives back the target node of an arc.
141
      /// \brief Return the target node of an arc.
138 142
      ///
139
      /// Gives back the target node of an arc.
143
      /// This function returns the target node of an arc.
144
      Node target(const Arc&) const { return INVALID; }
145

	
146
      /// \brief Return the opposite node on the given arc.
140 147
      ///
141
      Node target(const Arc&) const { return INVALID;}
142

	
143
      /// \brief Gives back the source node of an arc.
144
      ///
145
      /// Gives back the source node of an arc.
146
      ///
147
      Node source(const Arc&) const { return INVALID;}
148

	
149
      /// \brief Gives back the opposite node on the given arc.
150
      ///
151
      /// Gives back the opposite node on the given arc.
148
      /// This function returns the opposite node on the given arc.
152 149
      Node oppositeNode(const Node&, const Arc&) const {
153 150
        return INVALID;
154 151
      }
155 152

	
156 153
      template <typename _Digraph>
157 154
      struct Constraints {
158 155
        typedef typename _Digraph::Node Node;
159 156
        typedef typename _Digraph::Arc Arc;
160 157

	
161 158
        void constraints() {
162 159
          checkConcept<GraphItem<'n'>, Node>();
163 160
          checkConcept<GraphItem<'a'>, Arc>();
164 161
          {
165 162
            Node n;
166 163
            Arc e(INVALID);
167 164
            n = digraph.source(e);
168 165
            n = digraph.target(e);
169 166
            n = digraph.oppositeNode(n, e);
170 167
          }
171 168
        }
172 169

	
173 170
        const _Digraph& digraph;
174 171
      };
175 172
    };
176 173

	
177
    /// \brief An empty base undirected graph class.
174
    /// \brief Base skeleton class for undirected graphs.
178 175
    ///
179
    /// This class provides the minimal set of features needed for an
180
    /// undirected graph structure. All undirected graph concepts have
181
    /// to conform to this base graph. It just provides types for
182
    /// nodes, arcs and edges and functions to get the
183
    /// source and the target of the arcs and edges,
184
    /// conversion from arcs to edges and function to get
185
    /// both direction of the edges.
176
    /// This class describes the base interface of undirected graph types.
177
    /// All graph %concepts have to conform to this class.
178
    /// It extends the interface of \ref BaseDigraphComponent with an
179
    /// \c Edge type and functions to get the end nodes of edges,
180
    /// to convert from arcs to edges and to get both direction of edges.
186 181
    class BaseGraphComponent : public BaseDigraphComponent {
187 182
    public:
188 183
      typedef BaseDigraphComponent::Node Node;
189 184
      typedef BaseDigraphComponent::Arc Arc;
190
      /// \brief Undirected arc class of the graph.
185

	
186
      /// \brief Undirected edge class of the graph.
191 187
      ///
192
      /// This class represents the edges of the graph.
193
      /// The undirected graphs can be used as a directed graph which
194
      /// for each arc contains the opposite arc too so the graph is
195
      /// bidirected. The edge represents two opposite
196
      /// directed arcs.
197
      class Edge : public GraphItem<'u'> {
188
      /// This class represents the undirected edges of the graph.
189
      /// Undirected graphs can be used as directed graphs, each edge is
190
      /// represented by two opposite directed arcs.
191
      class Edge : public GraphItem<'e'> {
198 192
      public:
199
        typedef GraphItem<'u'> Parent;
193
        typedef GraphItem<'e'> Parent;
194

	
200 195
        /// \brief Default constructor.
201 196
        ///
197
        /// Default constructor.
202 198
        /// \warning The default constructor is not required to set
203 199
        /// the item to some well-defined value. So you should consider it
204 200
        /// as uninitialized.
205 201
        Edge() {}
202

	
206 203
        /// \brief Copy constructor.
207 204
        ///
208 205
        /// Copy constructor.
206
        Edge(const Edge &) : Parent() {}
207

	
208
        /// \brief Constructor for conversion from \c INVALID.
209 209
        ///
210
        Edge(const Edge &) : Parent() {}
211
        /// \brief Invalid constructor \& conversion.
212
        ///
213
        /// This constructor initializes the item to be invalid.
210
        /// Constructor for conversion from \c INVALID.
211
        /// It initializes the item to be invalid.
214 212
        /// \sa Invalid for more details.
215 213
        Edge(Invalid) {}
216
        /// \brief Converter from arc to edge.
214

	
215
        /// \brief Constructor for conversion from an arc.
217 216
        ///
217
        /// Constructor for conversion from an arc.
218 218
        /// Besides the core graph item functionality each arc should
219 219
        /// be convertible to the represented edge.
220 220
        Edge(const Arc&) {}
221
        /// \brief Assign arc to edge.
221

	
222
        /// \brief Assign an arc to an edge.
222 223
        ///
224
        /// This function assigns an arc to an edge.
223 225
        /// Besides the core graph item functionality each arc should
224 226
        /// be convertible to the represented edge.
225 227
        Edge& operator=(const Arc&) { return *this; }
226 228
      };
227 229

	
228
      /// \brief Returns the direction of the arc.
230
      /// \brief Return one end node of an edge.
231
      ///
232
      /// This function returns one end node of an edge.
233
      Node u(const Edge&) const { return INVALID; }
234

	
235
      /// \brief Return the other end node of an edge.
236
      ///
237
      /// This function returns the other end node of an edge.
238
      Node v(const Edge&) const { return INVALID; }
239

	
240
      /// \brief Return a directed arc related to an edge.
241
      ///
242
      /// This function returns a directed arc from its direction and the
243
      /// represented edge.
244
      Arc direct(const Edge&, bool) const { return INVALID; }
245

	
246
      /// \brief Return a directed arc related to an edge.
247
      ///
248
      /// This function returns a directed arc from its source node and the
249
      /// represented edge.
250
      Arc direct(const Edge&, const Node&) const { return INVALID; }
251

	
252
      /// \brief Return the direction of the arc.
229 253
      ///
230 254
      /// Returns the direction of the arc. Each arc represents an
231 255
      /// edge with a direction. It gives back the
232 256
      /// direction.
233 257
      bool direction(const Arc&) const { return true; }
234 258

	
235
      /// \brief Returns the directed arc.
259
      /// \brief Return the opposite arc.
236 260
      ///
237
      /// Returns the directed arc from its direction and the
238
      /// represented edge.
239
      Arc direct(const Edge&, bool) const { return INVALID;}
240

	
241
      /// \brief Returns the directed arc.
242
      ///
243
      /// Returns the directed arc from its source and the
244
      /// represented edge.
245
      Arc direct(const Edge&, const Node&) const { return INVALID;}
246

	
247
      /// \brief Returns the opposite arc.
248
      ///
249
      /// Returns the opposite arc. It is the arc representing the
250
      /// same edge and has opposite direction.
251
      Arc oppositeArc(const Arc&) const { return INVALID;}
252

	
253
      /// \brief Gives back one ending of an edge.
254
      ///
255
      /// Gives back one ending of an edge.
256
      Node u(const Edge&) const { return INVALID;}
257

	
258
      /// \brief Gives back the other ending of an edge.
259
      ///
260
      /// Gives back the other ending of an edge.
261
      Node v(const Edge&) const { return INVALID;}
261
      /// This function returns the opposite arc, i.e. the arc representing
262
      /// the same edge and has opposite direction.
263
      Arc oppositeArc(const Arc&) const { return INVALID; }
262 264

	
263 265
      template <typename _Graph>
264 266
      struct Constraints {
265 267
        typedef typename _Graph::Node Node;
266 268
        typedef typename _Graph::Arc Arc;
267 269
        typedef typename _Graph::Edge Edge;
268 270

	
269 271
        void constraints() {
270 272
          checkConcept<BaseDigraphComponent, _Graph>();
271
          checkConcept<GraphItem<'u'>, Edge>();
273
          checkConcept<GraphItem<'e'>, Edge>();
272 274
          {
273 275
            Node n;
274 276
            Edge ue(INVALID);
275 277
            Arc e;
276 278
            n = graph.u(ue);
277 279
            n = graph.v(ue);
278 280
            e = graph.direct(ue, true);
281
            e = graph.direct(ue, false);
279 282
            e = graph.direct(ue, n);
280 283
            e = graph.oppositeArc(e);
281 284
            ue = e;
282 285
            bool d = graph.direction(e);
283 286
            ignore_unused_variable_warning(d);
284 287
          }
285 288
        }
286 289

	
287 290
        const _Graph& graph;
288 291
      };
289 292

	
290 293
    };
291 294

	
292
    /// \brief An empty idable base digraph class.
295
    /// \brief Skeleton class for \e idable directed graphs.
293 296
    ///
294
    /// This class provides beside the core digraph features
295
    /// core id functions for the digraph structure.
296
    /// The most of the base digraphs should conform to this concept.
297
    /// The id's are unique and immutable.
297
    /// This class describes the interface of \e idable directed graphs.
298
    /// It extends \ref BaseDigraphComponent with the core ID functions.
299
    /// The ids of the items must be unique and immutable.
300
    /// This concept is part of the Digraph concept.
298 301
    template <typename BAS = BaseDigraphComponent>
299 302
    class IDableDigraphComponent : public BAS {
300 303
    public:
301 304

	
302 305
      typedef BAS Base;
303 306
      typedef typename Base::Node Node;
304 307
      typedef typename Base::Arc Arc;
305 308

	
306
      /// \brief Gives back an unique integer id for the Node.
309
      /// \brief Return a unique integer id for the given node.
307 310
      ///
308
      /// Gives back an unique integer id for the Node.
311
      /// This function returns a unique integer id for the given node.
312
      int id(const Node&) const { return -1; }
313

	
314
      /// \brief Return the node by its unique id.
309 315
      ///
310
      int id(const Node&) const { return -1;}
316
      /// This function returns the node by its unique id.
317
      /// If the digraph does not contain a node with the given id,
318
      /// then the result of the function is undefined.
319
      Node nodeFromId(int) const { return INVALID; }
311 320

	
312
      /// \brief Gives back the node by the unique id.
321
      /// \brief Return a unique integer id for the given arc.
313 322
      ///
314
      /// Gives back the node by the unique id.
315
      /// If the digraph does not contain node with the given id
316
      /// then the result of the function is undetermined.
317
      Node nodeFromId(int) const { return INVALID;}
323
      /// This function returns a unique integer id for the given arc.
324
      int id(const Arc&) const { return -1; }
318 325

	
319
      /// \brief Gives back an unique integer id for the Arc.
326
      /// \brief Return the arc by its unique id.
320 327
      ///
321
      /// Gives back an unique integer id for the Arc.
328
      /// This function returns the arc by its unique id.
329
      /// If the digraph does not contain an arc with the given id,
330
      /// then the result of the function is undefined.
331
      Arc arcFromId(int) const { return INVALID; }
332

	
333
      /// \brief Return an integer greater or equal to the maximum
334
      /// node id.
322 335
      ///
323
      int id(const Arc&) const { return -1;}
336
      /// This function returns an integer greater or equal to the
337
      /// maximum node id.
338
      int maxNodeId() const { return -1; }
324 339

	
325
      /// \brief Gives back the arc by the unique id.
340
      /// \brief Return an integer greater or equal to the maximum
341
      /// arc id.
326 342
      ///
327
      /// Gives back the arc by the unique id.
328
      /// If the digraph does not contain arc with the given id
329
      /// then the result of the function is undetermined.
330
      Arc arcFromId(int) const { return INVALID;}
331

	
332
      /// \brief Gives back an integer greater or equal to the maximum
333
      /// Node id.
334
      ///
335
      /// Gives back an integer greater or equal to the maximum Node
336
      /// id.
337
      int maxNodeId() const { return -1;}
338

	
339
      /// \brief Gives back an integer greater or equal to the maximum
340
      /// Arc id.
341
      ///
342
      /// Gives back an integer greater or equal to the maximum Arc
343
      /// id.
344
      int maxArcId() const { return -1;}
343
      /// This function returns an integer greater or equal to the
344
      /// maximum arc id.
345
      int maxArcId() const { return -1; }
345 346

	
346 347
      template <typename _Digraph>
347 348
      struct Constraints {
348 349

	
349 350
        void constraints() {
350 351
          checkConcept<Base, _Digraph >();
351 352
          typename _Digraph::Node node;
352 353
          int nid = digraph.id(node);
353 354
          nid = digraph.id(node);
354 355
          node = digraph.nodeFromId(nid);
355 356
          typename _Digraph::Arc arc;
356 357
          int eid = digraph.id(arc);
357 358
          eid = digraph.id(arc);
358 359
          arc = digraph.arcFromId(eid);
359 360

	
360 361
          nid = digraph.maxNodeId();
361 362
          ignore_unused_variable_warning(nid);
362 363
          eid = digraph.maxArcId();
363 364
          ignore_unused_variable_warning(eid);
364 365
        }
365 366

	
366 367
        const _Digraph& digraph;
367 368
      };
368 369
    };
369 370

	
370
    /// \brief An empty idable base undirected graph class.
371
    /// \brief Skeleton class for \e idable undirected graphs.
371 372
    ///
372
    /// This class provides beside the core undirected graph features
373
    /// core id functions for the undirected graph structure.  The
374
    /// most of the base undirected graphs should conform to this
375
    /// concept.  The id's are unique and immutable.
373
    /// This class describes the interface of \e idable undirected
374
    /// graphs. It extends \ref IDableDigraphComponent with the core ID
375
    /// functions of undirected graphs.
376
    /// The ids of the items must be unique and immutable.
377
    /// This concept is part of the Graph concept.
376 378
    template <typename BAS = BaseGraphComponent>
377 379
    class IDableGraphComponent : public IDableDigraphComponent<BAS> {
378 380
    public:
379 381

	
380 382
      typedef BAS Base;
381 383
      typedef typename Base::Edge Edge;
382 384

	
383 385
      using IDableDigraphComponent<Base>::id;
384 386

	
385
      /// \brief Gives back an unique integer id for the Edge.
387
      /// \brief Return a unique integer id for the given edge.
386 388
      ///
387
      /// Gives back an unique integer id for the Edge.
389
      /// This function returns a unique integer id for the given edge.
390
      int id(const Edge&) const { return -1; }
391

	
392
      /// \brief Return the edge by its unique id.
388 393
      ///
389
      int id(const Edge&) const { return -1;}
394
      /// This function returns the edge by its unique id.
395
      /// If the graph does not contain an edge with the given id,
396
      /// then the result of the function is undefined.
397
      Edge edgeFromId(int) const { return INVALID; }
390 398

	
391
      /// \brief Gives back the edge by the unique id.
399
      /// \brief Return an integer greater or equal to the maximum
400
      /// edge id.
392 401
      ///
393
      /// Gives back the edge by the unique id.  If the
394
      /// graph does not contain arc with the given id then the
395
      /// result of the function is undetermined.
396
      Edge edgeFromId(int) const { return INVALID;}
397

	
398
      /// \brief Gives back an integer greater or equal to the maximum
399
      /// Edge id.
400
      ///
401
      /// Gives back an integer greater or equal to the maximum Edge
402
      /// id.
403
      int maxEdgeId() const { return -1;}
402
      /// This function returns an integer greater or equal to the
403
      /// maximum edge id.
404
      int maxEdgeId() const { return -1; }
404 405

	
405 406
      template <typename _Graph>
406 407
      struct Constraints {
407 408

	
408 409
        void constraints() {
409
          checkConcept<Base, _Graph >();
410 410
          checkConcept<IDableDigraphComponent<Base>, _Graph >();
411 411
          typename _Graph::Edge edge;
412 412
          int ueid = graph.id(edge);
413 413
          ueid = graph.id(edge);
414 414
          edge = graph.edgeFromId(ueid);
415 415
          ueid = graph.maxEdgeId();
416 416
          ignore_unused_variable_warning(ueid);
417 417
        }
418 418

	
419 419
        const _Graph& graph;
420 420
      };
421 421
    };
422 422

	
423
    /// \brief Skeleton class for graph NodeIt and ArcIt
423
    /// \brief Concept class for \c NodeIt, \c ArcIt and \c EdgeIt types.
424 424
    ///
425
    /// Skeleton class for graph NodeIt and ArcIt.
426
    ///
425
    /// This class describes the concept of \c NodeIt, \c ArcIt and 
426
    /// \c EdgeIt subtypes of digraph and graph types.
427 427
    template <typename GR, typename Item>
428 428
    class GraphItemIt : public Item {
429 429
    public:
430 430
      /// \brief Default constructor.
431 431
      ///
432
      /// @warning The default constructor sets the iterator
433
      /// to an undefined value.
432
      /// Default constructor.
433
      /// \warning The default constructor is not required to set
434
      /// the iterator to some well-defined value. So you should consider it
435
      /// as uninitialized.
434 436
      GraphItemIt() {}
437

	
435 438
      /// \brief Copy constructor.
436 439
      ///
437 440
      /// Copy constructor.
441
      GraphItemIt(const GraphItemIt& it) : Item(it) {}
442

	
443
      /// \brief Constructor that sets the iterator to the first item.
438 444
      ///
439
      GraphItemIt(const GraphItemIt& ) {}
440
      /// \brief Sets the iterator to the first item.
445
      /// Constructor that sets the iterator to the first item.
446
      explicit GraphItemIt(const GR&) {}
447

	
448
      /// \brief Constructor for conversion from \c INVALID.
441 449
      ///
442
      /// Sets the iterator to the first item of \c the graph.
443
      ///
444
      explicit GraphItemIt(const GR&) {}
445
      /// \brief Invalid constructor \& conversion.
446
      ///
447
      /// This constructor initializes the item to be invalid.
450
      /// Constructor for conversion from \c INVALID.
451
      /// It initializes the iterator to be invalid.
448 452
      /// \sa Invalid for more details.
449 453
      GraphItemIt(Invalid) {}
450
      /// \brief Assign operator for items.
454

	
455
      /// \brief Assignment operator.
451 456
      ///
452
      /// The items are assignable.
457
      /// Assignment operator for the iterator.
458
      GraphItemIt& operator=(const GraphItemIt&) { return *this; }
459

	
460
      /// \brief Increment the iterator.
453 461
      ///
454
      GraphItemIt& operator=(const GraphItemIt&) { return *this; }
455
      /// \brief Next item.
456
      ///
457
      /// Assign the iterator to the next item.
458
      ///
462
      /// This operator increments the iterator, i.e. assigns it to the
463
      /// next item.
459 464
      GraphItemIt& operator++() { return *this; }
465
 
460 466
      /// \brief Equality operator
461 467
      ///
468
      /// Equality operator.
462 469
      /// Two iterators are equal if and only if they point to the
463 470
      /// same object or both are invalid.
464 471
      bool operator==(const GraphItemIt&) const { return true;}
472

	
465 473
      /// \brief Inequality operator
466 474
      ///
467
      /// \sa operator==(Node n)
468
      ///
475
      /// Inequality operator.
476
      /// Two iterators are equal if and only if they point to the
477
      /// same object or both are invalid.
469 478
      bool operator!=(const GraphItemIt&) const { return true;}
470 479

	
471 480
      template<typename _GraphItemIt>
472 481
      struct Constraints {
473 482
        void constraints() {
483
          checkConcept<GraphItem<>, _GraphItemIt>();
474 484
          _GraphItemIt it1(g);
475 485
          _GraphItemIt it2;
486
          _GraphItemIt it3 = it1;
487
          _GraphItemIt it4 = INVALID;
476 488

	
477 489
          it2 = ++it1;
478 490
          ++it2 = it1;
479 491
          ++(++it1);
480 492

	
481 493
          Item bi = it1;
482 494
          bi = it2;
483 495
        }
484
        GR& g;
496
        const GR& g;
485 497
      };
486 498
    };
487 499

	
488
    /// \brief Skeleton class for graph InArcIt and OutArcIt
500
    /// \brief Concept class for \c InArcIt, \c OutArcIt and 
501
    /// \c IncEdgeIt types.
489 502
    ///
490
    /// \note Because InArcIt and OutArcIt may not inherit from the same
491
    /// base class, the \c sel is a additional template parameter (selector).
492
    /// For InArcIt you should instantiate it with character 'i' and for
493
    /// OutArcIt with 'o'.
503
    /// This class describes the concept of \c InArcIt, \c OutArcIt 
504
    /// and \c IncEdgeIt subtypes of digraph and graph types.
505
    ///
506
    /// \note Since these iterator classes do not inherit from the same
507
    /// base class, there is an additional template parameter (selector)
508
    /// \c sel. For \c InArcIt you should instantiate it with character 
509
    /// \c 'i', for \c OutArcIt with \c 'o' and for \c IncEdgeIt with \c 'e'.
494 510
    template <typename GR,
495 511
              typename Item = typename GR::Arc,
496 512
              typename Base = typename GR::Node,
497 513
              char sel = '0'>
498 514
    class GraphIncIt : public Item {
499 515
    public:
500 516
      /// \brief Default constructor.
501 517
      ///
502
      /// @warning The default constructor sets the iterator
503
      /// to an undefined value.
518
      /// Default constructor.
519
      /// \warning The default constructor is not required to set
520
      /// the iterator to some well-defined value. So you should consider it
521
      /// as uninitialized.
504 522
      GraphIncIt() {}
523

	
505 524
      /// \brief Copy constructor.
506 525
      ///
507 526
      /// Copy constructor.
527
      GraphIncIt(const GraphIncIt& it) : Item(it) {}
528

	
529
      /// \brief Constructor that sets the iterator to the first 
530
      /// incoming or outgoing arc.
508 531
      ///
509
      GraphIncIt(GraphIncIt const& gi) : Item(gi) {}
510
      /// \brief Sets the iterator to the first arc incoming into or outgoing
511
      /// from the node.
532
      /// Constructor that sets the iterator to the first arc 
533
      /// incoming to or outgoing from the given node.
534
      explicit GraphIncIt(const GR&, const Base&) {}
535

	
536
      /// \brief Constructor for conversion from \c INVALID.
512 537
      ///
513
      /// Sets the iterator to the first arc incoming into or outgoing
514
      /// from the node.
515
      ///
516
      explicit GraphIncIt(const GR&, const Base&) {}
517
      /// \brief Invalid constructor \& conversion.
518
      ///
519
      /// This constructor initializes the item to be invalid.
538
      /// Constructor for conversion from \c INVALID.
539
      /// It initializes the iterator to be invalid.
520 540
      /// \sa Invalid for more details.
521 541
      GraphIncIt(Invalid) {}
522
      /// \brief Assign operator for iterators.
542

	
543
      /// \brief Assignment operator.
523 544
      ///
524
      /// The iterators are assignable.
545
      /// Assignment operator for the iterator.
546
      GraphIncIt& operator=(const GraphIncIt&) { return *this; }
547

	
548
      /// \brief Increment the iterator.
525 549
      ///
526
      GraphIncIt& operator=(GraphIncIt const&) { return *this; }
527
      /// \brief Next item.
528
      ///
529
      /// Assign the iterator to the next item.
530
      ///
550
      /// This operator increments the iterator, i.e. assigns it to the
551
      /// next arc incoming to or outgoing from the given node.
531 552
      GraphIncIt& operator++() { return *this; }
532 553

	
533 554
      /// \brief Equality operator
534 555
      ///
556
      /// Equality operator.
535 557
      /// Two iterators are equal if and only if they point to the
536 558
      /// same object or both are invalid.
537 559
      bool operator==(const GraphIncIt&) const { return true;}
538 560

	
539 561
      /// \brief Inequality operator
540 562
      ///
541
      /// \sa operator==(Node n)
542
      ///
563
      /// Inequality operator.
564
      /// Two iterators are equal if and only if they point to the
565
      /// same object or both are invalid.
543 566
      bool operator!=(const GraphIncIt&) const { return true;}
544 567

	
545 568
      template <typename _GraphIncIt>
546 569
      struct Constraints {
547 570
        void constraints() {
548 571
          checkConcept<GraphItem<sel>, _GraphIncIt>();
549 572
          _GraphIncIt it1(graph, node);
550 573
          _GraphIncIt it2;
574
          _GraphIncIt it3 = it1;
575
          _GraphIncIt it4 = INVALID;
551 576

	
552 577
          it2 = ++it1;
553 578
          ++it2 = it1;
554 579
          ++(++it1);
555 580
          Item e = it1;
556 581
          e = it2;
557

	
558 582
        }
559

	
560
        Item arc;
561
        Base node;
562
        GR graph;
563
        _GraphIncIt it;
583
        const Base& node;
584
        const GR& graph;
564 585
      };
565 586
    };
566 587

	
567

	
568
    /// \brief An empty iterable digraph class.
588
    /// \brief Skeleton class for iterable directed graphs.
569 589
    ///
570
    /// This class provides beside the core digraph features
571
    /// iterator based iterable interface for the digraph structure.
590
    /// This class describes the interface of iterable directed
591
    /// graphs. It extends \ref BaseDigraphComponent with the core
592
    /// iterable interface.
572 593
    /// This concept is part of the Digraph concept.
573 594
    template <typename BAS = BaseDigraphComponent>
574 595
    class IterableDigraphComponent : public BAS {
575 596

	
576 597
    public:
577 598

	
578 599
      typedef BAS Base;
579 600
      typedef typename Base::Node Node;
580 601
      typedef typename Base::Arc Arc;
581 602

	
582 603
      typedef IterableDigraphComponent Digraph;
583 604

	
584 605
      /// \name Base iteration
585 606
      ///
586
      /// This interface provides functions for iteration on digraph items
607
      /// This interface provides functions for iteration on digraph items.
587 608
      ///
588 609
      /// @{
589 610

	
590
      /// \brief Gives back the first node in the iterating order.
611
      /// \brief Return the first node.
591 612
      ///
592
      /// Gives back the first node in the iterating order.
593
      ///
613
      /// This function gives back the first node in the iteration order.
594 614
      void first(Node&) const {}
595 615

	
596
      /// \brief Gives back the next node in the iterating order.
616
      /// \brief Return the next node.
597 617
      ///
598
      /// Gives back the next node in the iterating order.
599
      ///
618
      /// This function gives back the next node in the iteration order.
600 619
      void next(Node&) const {}
601 620

	
602
      /// \brief Gives back the first arc in the iterating order.
621
      /// \brief Return the first arc.
603 622
      ///
604
      /// Gives back the first arc in the iterating order.
605
      ///
623
      /// This function gives back the first arc in the iteration order.
606 624
      void first(Arc&) const {}
607 625

	
608
      /// \brief Gives back the next arc in the iterating order.
626
      /// \brief Return the next arc.
609 627
      ///
610
      /// Gives back the next arc in the iterating order.
611
      ///
628
      /// This function gives back the next arc in the iteration order.
612 629
      void next(Arc&) const {}
613 630

	
614

	
615
      /// \brief Gives back the first of the arcs point to the given
616
      /// node.
631
      /// \brief Return the first arc incomming to the given node.
617 632
      ///
618
      /// Gives back the first of the arcs point to the given node.
619
      ///
633
      /// This function gives back the first arc incomming to the
634
      /// given node.
620 635
      void firstIn(Arc&, const Node&) const {}
621 636

	
622
      /// \brief Gives back the next of the arcs points to the given
623
      /// node.
637
      /// \brief Return the next arc incomming to the given node.
624 638
      ///
625
      /// Gives back the next of the arcs points to the given node.
626
      ///
639
      /// This function gives back the next arc incomming to the
640
      /// given node.
627 641
      void nextIn(Arc&) const {}
628 642

	
629
      /// \brief Gives back the first of the arcs start from the
643
      /// \brief Return the first arc outgoing form the given node.
644
      ///
645
      /// This function gives back the first arc outgoing form the
630 646
      /// given node.
631
      ///
632
      /// Gives back the first of the arcs start from the given node.
633
      ///
634 647
      void firstOut(Arc&, const Node&) const {}
635 648

	
636
      /// \brief Gives back the next of the arcs start from the given
637
      /// node.
649
      /// \brief Return the next arc outgoing form the given node.
638 650
      ///
639
      /// Gives back the next of the arcs start from the given node.
640
      ///
651
      /// This function gives back the next arc outgoing form the
652
      /// given node.
641 653
      void nextOut(Arc&) const {}
642 654

	
643 655
      /// @}
644 656

	
645 657
      /// \name Class based iteration
646 658
      ///
647
      /// This interface provides functions for iteration on digraph items
659
      /// This interface provides iterator classes for digraph items.
648 660
      ///
649 661
      /// @{
650 662

	
651 663
      /// \brief This iterator goes through each node.
652 664
      ///
653 665
      /// This iterator goes through each node.
654 666
      ///
655 667
      typedef GraphItemIt<Digraph, Node> NodeIt;
656 668

	
657
      /// \brief This iterator goes through each node.
669
      /// \brief This iterator goes through each arc.
658 670
      ///
659
      /// This iterator goes through each node.
671
      /// This iterator goes through each arc.
660 672
      ///
661 673
      typedef GraphItemIt<Digraph, Arc> ArcIt;
662 674

	
663 675
      /// \brief This iterator goes trough the incoming arcs of a node.
664 676
      ///
665
      /// This iterator goes trough the \e inccoming arcs of a certain node
677
      /// This iterator goes trough the \e incoming arcs of a certain node
666 678
      /// of a digraph.
667 679
      typedef GraphIncIt<Digraph, Arc, Node, 'i'> InArcIt;
668 680

	
669 681
      /// \brief This iterator goes trough the outgoing arcs of a node.
670 682
      ///
671 683
      /// This iterator goes trough the \e outgoing arcs of a certain node
672 684
      /// of a digraph.
673 685
      typedef GraphIncIt<Digraph, Arc, Node, 'o'> OutArcIt;
674 686

	
675 687
      /// \brief The base node of the iterator.
676 688
      ///
677
      /// Gives back the base node of the iterator.
678
      /// It is always the target of the pointed arc.
689
      /// This function gives back the base node of the iterator.
690
      /// It is always the target node of the pointed arc.
679 691
      Node baseNode(const InArcIt&) const { return INVALID; }
680 692

	
681 693
      /// \brief The running node of the iterator.
682 694
      ///
683
      /// Gives back the running node of the iterator.
684
      /// It is always the source of the pointed arc.
695
      /// This function gives back the running node of the iterator.
696
      /// It is always the source node of the pointed arc.
685 697
      Node runningNode(const InArcIt&) const { return INVALID; }
686 698

	
687 699
      /// \brief The base node of the iterator.
688 700
      ///
689
      /// Gives back the base node of the iterator.
690
      /// It is always the source of the pointed arc.
701
      /// This function gives back the base node of the iterator.
702
      /// It is always the source node of the pointed arc.
691 703
      Node baseNode(const OutArcIt&) const { return INVALID; }
692 704

	
693 705
      /// \brief The running node of the iterator.
694 706
      ///
695
      /// Gives back the running node of the iterator.
696
      /// It is always the target of the pointed arc.
707
      /// This function gives back the running node of the iterator.
708
      /// It is always the target node of the pointed arc.
697 709
      Node runningNode(const OutArcIt&) const { return INVALID; }
698 710

	
699 711
      /// @}
700 712

	
701 713
      template <typename _Digraph>
702 714
      struct Constraints {
703 715
        void constraints() {
704 716
          checkConcept<Base, _Digraph>();
705 717

	
706 718
          {
707 719
            typename _Digraph::Node node(INVALID);
708 720
            typename _Digraph::Arc arc(INVALID);
709 721
            {
710 722
              digraph.first(node);
711 723
              digraph.next(node);
712 724
            }
713 725
            {
714 726
              digraph.first(arc);
715 727
              digraph.next(arc);
716 728
            }
717 729
            {
718 730
              digraph.firstIn(arc, node);
719 731
              digraph.nextIn(arc);
720 732
            }
721 733
            {
722 734
              digraph.firstOut(arc, node);
723 735
              digraph.nextOut(arc);
724 736
            }
725 737
          }
726 738

	
727 739
          {
728 740
            checkConcept<GraphItemIt<_Digraph, typename _Digraph::Arc>,
729 741
              typename _Digraph::ArcIt >();
730 742
            checkConcept<GraphItemIt<_Digraph, typename _Digraph::Node>,
731 743
              typename _Digraph::NodeIt >();
732 744
            checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc,
733 745
              typename _Digraph::Node, 'i'>, typename _Digraph::InArcIt>();
734 746
            checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc,
735 747
              typename _Digraph::Node, 'o'>, typename _Digraph::OutArcIt>();
736 748

	
737 749
            typename _Digraph::Node n;
738
            typename _Digraph::InArcIt ieit(INVALID);
739
            typename _Digraph::OutArcIt oeit(INVALID);
740
            n = digraph.baseNode(ieit);
741
            n = digraph.runningNode(ieit);
742
            n = digraph.baseNode(oeit);
743
            n = digraph.runningNode(oeit);
750
            const typename _Digraph::InArcIt iait(INVALID);
751
            const typename _Digraph::OutArcIt oait(INVALID);
752
            n = digraph.baseNode(iait);
753
            n = digraph.runningNode(iait);
754
            n = digraph.baseNode(oait);
755
            n = digraph.runningNode(oait);
744 756
            ignore_unused_variable_warning(n);
745 757
          }
746 758
        }
747 759

	
748 760
        const _Digraph& digraph;
749

	
750 761
      };
751 762
    };
752 763

	
753
    /// \brief An empty iterable undirected graph class.
764
    /// \brief Skeleton class for iterable undirected graphs.
754 765
    ///
755
    /// This class provides beside the core graph features iterator
756
    /// based iterable interface for the undirected graph structure.
766
    /// This class describes the interface of iterable undirected
767
    /// graphs. It extends \ref IterableDigraphComponent with the core
768
    /// iterable interface of undirected graphs.
757 769
    /// This concept is part of the Graph concept.
758 770
    template <typename BAS = BaseGraphComponent>
759 771
    class IterableGraphComponent : public IterableDigraphComponent<BAS> {
760 772
    public:
761 773

	
762 774
      typedef BAS Base;
763 775
      typedef typename Base::Node Node;
764 776
      typedef typename Base::Arc Arc;
765 777
      typedef typename Base::Edge Edge;
766 778

	
767 779

	
768 780
      typedef IterableGraphComponent Graph;
769 781

	
770 782
      /// \name Base iteration
771 783
      ///
772
      /// This interface provides functions for iteration on graph items
784
      /// This interface provides functions for iteration on edges.
785
      ///
773 786
      /// @{
774 787

	
775 788
      using IterableDigraphComponent<Base>::first;
776 789
      using IterableDigraphComponent<Base>::next;
777 790

	
778
      /// \brief Gives back the first edge in the iterating
779
      /// order.
791
      /// \brief Return the first edge.
780 792
      ///
781
      /// Gives back the first edge in the iterating order.
782
      ///
793
      /// This function gives back the first edge in the iteration order.
783 794
      void first(Edge&) const {}
784 795

	
785
      /// \brief Gives back the next edge in the iterating
786
      /// order.
796
      /// \brief Return the next edge.
787 797
      ///
788
      /// Gives back the next edge in the iterating order.
789
      ///
798
      /// This function gives back the next edge in the iteration order.
790 799
      void next(Edge&) const {}
791 800

	
792

	
793
      /// \brief Gives back the first of the edges from the
801
      /// \brief Return the first edge incident to the given node.
802
      ///
803
      /// This function gives back the first edge incident to the given 
804
      /// node. The bool parameter gives back the direction for which the
805
      /// source node of the directed arc representing the edge is the 
794 806
      /// given node.
795
      ///
796
      /// Gives back the first of the edges from the given
797
      /// node. The bool parameter gives back that direction which
798
      /// gives a good direction of the edge so the source of the
799
      /// directed arc is the given node.
800 807
      void firstInc(Edge&, bool&, const Node&) const {}
801 808

	
802 809
      /// \brief Gives back the next of the edges from the
803 810
      /// given node.
804 811
      ///
805
      /// Gives back the next of the edges from the given
806
      /// node. The bool parameter should be used as the \c firstInc()
807
      /// use it.
812
      /// This function gives back the next edge incident to the given 
813
      /// node. The bool parameter should be used as \c firstInc() use it.
808 814
      void nextInc(Edge&, bool&) const {}
809 815

	
810 816
      using IterableDigraphComponent<Base>::baseNode;
811 817
      using IterableDigraphComponent<Base>::runningNode;
812 818

	
813 819
      /// @}
814 820

	
815 821
      /// \name Class based iteration
816 822
      ///
817
      /// This interface provides functions for iteration on graph items
823
      /// This interface provides iterator classes for edges.
818 824
      ///
819 825
      /// @{
820 826

	
821
      /// \brief This iterator goes through each node.
827
      /// \brief This iterator goes through each edge.
822 828
      ///
823
      /// This iterator goes through each node.
829
      /// This iterator goes through each edge.
824 830
      typedef GraphItemIt<Graph, Edge> EdgeIt;
825
      /// \brief This iterator goes trough the incident arcs of a
831

	
832
      /// \brief This iterator goes trough the incident edges of a
826 833
      /// node.
827 834
      ///
828
      /// This iterator goes trough the incident arcs of a certain
835
      /// This iterator goes trough the incident edges of a certain
829 836
      /// node of a graph.
830
      typedef GraphIncIt<Graph, Edge, Node, 'u'> IncEdgeIt;
837
      typedef GraphIncIt<Graph, Edge, Node, 'e'> IncEdgeIt;
838

	
831 839
      /// \brief The base node of the iterator.
832 840
      ///
833
      /// Gives back the base node of the iterator.
841
      /// This function gives back the base node of the iterator.
834 842
      Node baseNode(const IncEdgeIt&) const { return INVALID; }
835 843

	
836 844
      /// \brief The running node of the iterator.
837 845
      ///
838
      /// Gives back the running node of the iterator.
846
      /// This function gives back the running node of the iterator.
839 847
      Node runningNode(const IncEdgeIt&) const { return INVALID; }
840 848

	
841 849
      /// @}
842 850

	
843 851
      template <typename _Graph>
844 852
      struct Constraints {
845 853
        void constraints() {
846 854
          checkConcept<IterableDigraphComponent<Base>, _Graph>();
847 855

	
848 856
          {
849 857
            typename _Graph::Node node(INVALID);
850 858
            typename _Graph::Edge edge(INVALID);
851 859
            bool dir;
852 860
            {
853 861
              graph.first(edge);
854 862
              graph.next(edge);
855 863
            }
856 864
            {
857 865
              graph.firstInc(edge, dir, node);
858 866
              graph.nextInc(edge, dir);
859 867
            }
860 868

	
861 869
          }
862 870

	
863 871
          {
864 872
            checkConcept<GraphItemIt<_Graph, typename _Graph::Edge>,
865 873
              typename _Graph::EdgeIt >();
866 874
            checkConcept<GraphIncIt<_Graph, typename _Graph::Edge,
867
              typename _Graph::Node, 'u'>, typename _Graph::IncEdgeIt>();
875
              typename _Graph::Node, 'e'>, typename _Graph::IncEdgeIt>();
868 876

	
869 877
            typename _Graph::Node n;
870
            typename _Graph::IncEdgeIt ueit(INVALID);
871
            n = graph.baseNode(ueit);
872
            n = graph.runningNode(ueit);
878
            const typename _Graph::IncEdgeIt ieit(INVALID);
879
            n = graph.baseNode(ieit);
880
            n = graph.runningNode(ieit);
873 881
          }
874 882
        }
875 883

	
876 884
        const _Graph& graph;
877 885
      };
878 886
    };
879 887

	
880
    /// \brief An empty alteration notifier digraph class.
888
    /// \brief Skeleton class for alterable directed graphs.
881 889
    ///
882
    /// This class provides beside the core digraph features alteration
883
    /// notifier interface for the digraph structure.  This implements
890
    /// This class describes the interface of alterable directed
891
    /// graphs. It extends \ref BaseDigraphComponent with the alteration
892
    /// notifier interface. It implements
884 893
    /// an observer-notifier pattern for each digraph item. More
885 894
    /// obsevers can be registered into the notifier and whenever an
886
    /// alteration occured in the digraph all the observers will
895
    /// alteration occured in the digraph all the observers will be
887 896
    /// notified about it.
888 897
    template <typename BAS = BaseDigraphComponent>
889 898
    class AlterableDigraphComponent : public BAS {
890 899
    public:
891 900

	
892 901
      typedef BAS Base;
893 902
      typedef typename Base::Node Node;
894 903
      typedef typename Base::Arc Arc;
895 904

	
896 905

	
897
      /// The node observer registry.
906
      /// Node alteration notifier class.
898 907
      typedef AlterationNotifier<AlterableDigraphComponent, Node>
899 908
      NodeNotifier;
900
      /// The arc observer registry.
909
      /// Arc alteration notifier class.
901 910
      typedef AlterationNotifier<AlterableDigraphComponent, Arc>
902 911
      ArcNotifier;
903 912

	
904
      /// \brief Gives back the node alteration notifier.
913
      /// \brief Return the node alteration notifier.
905 914
      ///
906
      /// Gives back the node alteration notifier.
915
      /// This function gives back the node alteration notifier.
907 916
      NodeNotifier& notifier(Node) const {
908
        return NodeNotifier();
917
         return NodeNotifier();
909 918
      }
910 919

	
911
      /// \brief Gives back the arc alteration notifier.
920
      /// \brief Return the arc alteration notifier.
912 921
      ///
913
      /// Gives back the arc alteration notifier.
922
      /// This function gives back the arc alteration notifier.
914 923
      ArcNotifier& notifier(Arc) const {
915 924
        return ArcNotifier();
916 925
      }
917 926

	
918 927
      template <typename _Digraph>
919 928
      struct Constraints {
920 929
        void constraints() {
921 930
          checkConcept<Base, _Digraph>();
922 931
          typename _Digraph::NodeNotifier& nn
923 932
            = digraph.notifier(typename _Digraph::Node());
924 933

	
925 934
          typename _Digraph::ArcNotifier& en
926 935
            = digraph.notifier(typename _Digraph::Arc());
927 936

	
928 937
          ignore_unused_variable_warning(nn);
929 938
          ignore_unused_variable_warning(en);
930 939
        }
931 940

	
932 941
        const _Digraph& digraph;
933

	
934 942
      };
935

	
936 943
    };
937 944

	
938
    /// \brief An empty alteration notifier undirected graph class.
945
    /// \brief Skeleton class for alterable undirected graphs.
939 946
    ///
940
    /// This class provides beside the core graph features alteration
941
    /// notifier interface for the graph structure.  This implements
942
    /// an observer-notifier pattern for each graph item. More
947
    /// This class describes the interface of alterable undirected
948
    /// graphs. It extends \ref AlterableDigraphComponent with the alteration
949
    /// notifier interface of undirected graphs. It implements
950
    /// an observer-notifier pattern for the edges. More
943 951
    /// obsevers can be registered into the notifier and whenever an
944
    /// alteration occured in the graph all the observers will
952
    /// alteration occured in the graph all the observers will be
945 953
    /// notified about it.
946 954
    template <typename BAS = BaseGraphComponent>
947 955
    class AlterableGraphComponent : public AlterableDigraphComponent<BAS> {
948 956
    public:
949 957

	
950 958
      typedef BAS Base;
951 959
      typedef typename Base::Edge Edge;
952 960

	
953 961

	
954
      /// The arc observer registry.
962
      /// Edge alteration notifier class.
955 963
      typedef AlterationNotifier<AlterableGraphComponent, Edge>
956 964
      EdgeNotifier;
957 965

	
958
      /// \brief Gives back the arc alteration notifier.
966
      /// \brief Return the edge alteration notifier.
959 967
      ///
960
      /// Gives back the arc alteration notifier.
968
      /// This function gives back the edge alteration notifier.
961 969
      EdgeNotifier& notifier(Edge) const {
962 970
        return EdgeNotifier();
963 971
      }
964 972

	
965 973
      template <typename _Graph>
966 974
      struct Constraints {
967 975
        void constraints() {
968
          checkConcept<AlterableGraphComponent<Base>, _Graph>();
976
          checkConcept<AlterableDigraphComponent<Base>, _Graph>();
969 977
          typename _Graph::EdgeNotifier& uen
970 978
            = graph.notifier(typename _Graph::Edge());
971 979
          ignore_unused_variable_warning(uen);
972 980
        }
973 981

	
974 982
        const _Graph& graph;
975 983
      };
976 984
    };
977 985

	
978
    /// \brief Class describing the concept of graph maps
986
    /// \brief Concept class for standard graph maps.
979 987
    ///
980
    /// This class describes the common interface of the graph maps
981
    /// (NodeMap, ArcMap), that is maps that can be used to
982
    /// associate data to graph descriptors (nodes or arcs).
988
    /// This class describes the concept of standard graph maps, i.e.
989
    /// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and 
990
    /// graph types, which can be used for associating data to graph items.
983 991
    template <typename GR, typename K, typename V>
984 992
    class GraphMap : public ReadWriteMap<K, V> {
985 993
    public:
986 994

	
987 995
      typedef ReadWriteMap<K, V> Parent;
988 996

	
989 997
      /// The graph type of the map.
990 998
      typedef GR Graph;
991 999
      /// The key type of the map.
992 1000
      typedef K Key;
993 1001
      /// The value type of the map.
994 1002
      typedef V Value;
995 1003

	
996 1004
      /// \brief Construct a new map.
997 1005
      ///
998 1006
      /// Construct a new map for the graph.
999 1007
      explicit GraphMap(const Graph&) {}
1000 1008
      /// \brief Construct a new map with default value.
1001 1009
      ///
1002
      /// Construct a new map for the graph and initalise the values.
1010
      /// Construct a new map for the graph and initalize the values.
1003 1011
      GraphMap(const Graph&, const Value&) {}
1004 1012

	
1005 1013
    private:
1006 1014
      /// \brief Copy constructor.
1007 1015
      ///
1008 1016
      /// Copy Constructor.
1009 1017
      GraphMap(const GraphMap&) : Parent() {}
1010 1018

	
1011
      /// \brief Assign operator.
1019
      /// \brief Assignment operator.
1012 1020
      ///
1013
      /// Assign operator. It does not mofify the underlying graph,
1021
      /// Assignment operator. It does not mofify the underlying graph,
1014 1022
      /// it just iterates on the current item set and set the  map
1015 1023
      /// with the value returned by the assigned map.
1016 1024
      template <typename CMap>
1017 1025
      GraphMap& operator=(const CMap&) {
1018 1026
        checkConcept<ReadMap<Key, Value>, CMap>();
1019 1027
        return *this;
1020 1028
      }
1021 1029

	
1022 1030
    public:
1023 1031
      template<typename _Map>
1024 1032
      struct Constraints {
1025 1033
        void constraints() {
1026 1034
          checkConcept<ReadWriteMap<Key, Value>, _Map >();
1027
          // Construction with a graph parameter
1028
          _Map a(g);
1029
          // Constructor with a graph and a default value parameter
1030
          _Map a2(g,t);
1031
          // Copy constructor.
1032
          // _Map b(c);
1035
          _Map m1(g);
1036
          _Map m2(g,t);
1037
          
1038
          // Copy constructor
1039
          // _Map m3(m);
1033 1040

	
1041
          // Assignment operator
1034 1042
          // ReadMap<Key, Value> cmap;
1035
          // b = cmap;
1043
          // m3 = cmap;
1036 1044

	
1037
          ignore_unused_variable_warning(a);
1038
          ignore_unused_variable_warning(a2);
1039
          // ignore_unused_variable_warning(b);
1045
          ignore_unused_variable_warning(m1);
1046
          ignore_unused_variable_warning(m2);
1047
          // ignore_unused_variable_warning(m3);
1040 1048
        }
1041 1049

	
1042
        const _Map &c;
1050
        const _Map &m;
1043 1051
        const Graph &g;
1044 1052
        const typename GraphMap::Value &t;
1045 1053
      };
1046 1054

	
1047 1055
    };
1048 1056

	
1049
    /// \brief An empty mappable digraph class.
1057
    /// \brief Skeleton class for mappable directed graphs.
1050 1058
    ///
1051
    /// This class provides beside the core digraph features
1052
    /// map interface for the digraph structure.
1059
    /// This class describes the interface of mappable directed graphs.
1060
    /// It extends \ref BaseDigraphComponent with the standard digraph 
1061
    /// map classes, namely \c NodeMap and \c ArcMap.
1053 1062
    /// This concept is part of the Digraph concept.
1054 1063
    template <typename BAS = BaseDigraphComponent>
1055 1064
    class MappableDigraphComponent : public BAS  {
1056 1065
    public:
1057 1066

	
1058 1067
      typedef BAS Base;
1059 1068
      typedef typename Base::Node Node;
1060 1069
      typedef typename Base::Arc Arc;
1061 1070

	
1062 1071
      typedef MappableDigraphComponent Digraph;
1063 1072

	
1064
      /// \brief ReadWrite map of the nodes.
1073
      /// \brief Standard graph map for the nodes.
1065 1074
      ///
1066
      /// ReadWrite map of the nodes.
1067
      ///
1075
      /// Standard graph map for the nodes.
1068 1076
      template <typename V>
1069
      class NodeMap : public GraphMap<Digraph, Node, V> {
1077
      class NodeMap : public GraphMap<MappableDigraphComponent, Node, V> {
1070 1078
      public:
1071 1079
        typedef GraphMap<MappableDigraphComponent, Node, V> Parent;
1072 1080

	
1073 1081
        /// \brief Construct a new map.
1074 1082
        ///
1075 1083
        /// Construct a new map for the digraph.
1076 1084
        explicit NodeMap(const MappableDigraphComponent& digraph)
1077 1085
          : Parent(digraph) {}
1078 1086

	
1079 1087
        /// \brief Construct a new map with default value.
1080 1088
        ///
1081
        /// Construct a new map for the digraph and initalise the values.
1089
        /// Construct a new map for the digraph and initalize the values.
1082 1090
        NodeMap(const MappableDigraphComponent& digraph, const V& value)
1083 1091
          : Parent(digraph, value) {}
1084 1092

	
1085 1093
      private:
1086 1094
        /// \brief Copy constructor.
1087 1095
        ///
1088 1096
        /// Copy Constructor.
1089 1097
        NodeMap(const NodeMap& nm) : Parent(nm) {}
1090 1098

	
1091
        /// \brief Assign operator.
1099
        /// \brief Assignment operator.
1092 1100
        ///
1093
        /// Assign operator.
1101
        /// Assignment operator.
1094 1102
        template <typename CMap>
1095 1103
        NodeMap& operator=(const CMap&) {
1096 1104
          checkConcept<ReadMap<Node, V>, CMap>();
1097 1105
          return *this;
1098 1106
        }
1099 1107

	
1100 1108
      };
1101 1109

	
1102
      /// \brief ReadWrite map of the arcs.
1110
      /// \brief Standard graph map for the arcs.
1103 1111
      ///
1104
      /// ReadWrite map of the arcs.
1105
      ///
1112
      /// Standard graph map for the arcs.
1106 1113
      template <typename V>
1107
      class ArcMap : public GraphMap<Digraph, Arc, V> {
1114
      class ArcMap : public GraphMap<MappableDigraphComponent, Arc, V> {
1108 1115
      public:
1109 1116
        typedef GraphMap<MappableDigraphComponent, Arc, V> Parent;
1110 1117

	
1111 1118
        /// \brief Construct a new map.
1112 1119
        ///
1113 1120
        /// Construct a new map for the digraph.
1114 1121
        explicit ArcMap(const MappableDigraphComponent& digraph)
1115 1122
          : Parent(digraph) {}
1116 1123

	
1117 1124
        /// \brief Construct a new map with default value.
1118 1125
        ///
1119
        /// Construct a new map for the digraph and initalise the values.
1126
        /// Construct a new map for the digraph and initalize the values.
1120 1127
        ArcMap(const MappableDigraphComponent& digraph, const V& value)
1121 1128
          : Parent(digraph, value) {}
1122 1129

	
1123 1130
      private:
1124 1131
        /// \brief Copy constructor.
1125 1132
        ///
1126 1133
        /// Copy Constructor.
1127 1134
        ArcMap(const ArcMap& nm) : Parent(nm) {}
1128 1135

	
1129
        /// \brief Assign operator.
1136
        /// \brief Assignment operator.
1130 1137
        ///
1131
        /// Assign operator.
1138
        /// Assignment operator.
1132 1139
        template <typename CMap>
1133 1140
        ArcMap& operator=(const CMap&) {
1134 1141
          checkConcept<ReadMap<Arc, V>, CMap>();
1135 1142
          return *this;
1136 1143
        }
1137 1144

	
1138 1145
      };
1139 1146

	
1140 1147

	
1141 1148
      template <typename _Digraph>
1142 1149
      struct Constraints {
1143 1150

	
1144 1151
        struct Dummy {
1145 1152
          int value;
1146 1153
          Dummy() : value(0) {}
1147 1154
          Dummy(int _v) : value(_v) {}
1148 1155
        };
1149 1156

	
1150 1157
        void constraints() {
1151 1158
          checkConcept<Base, _Digraph>();
1152 1159
          { // int map test
1153 1160
            typedef typename _Digraph::template NodeMap<int> IntNodeMap;
1154 1161
            checkConcept<GraphMap<_Digraph, typename _Digraph::Node, int>,
1155 1162
              IntNodeMap >();
1156 1163
          } { // bool map test
1157 1164
            typedef typename _Digraph::template NodeMap<bool> BoolNodeMap;
1158 1165
            checkConcept<GraphMap<_Digraph, typename _Digraph::Node, bool>,
1159 1166
              BoolNodeMap >();
1160 1167
          } { // Dummy map test
1161 1168
            typedef typename _Digraph::template NodeMap<Dummy> DummyNodeMap;
1162 1169
            checkConcept<GraphMap<_Digraph, typename _Digraph::Node, Dummy>,
1163 1170
              DummyNodeMap >();
1164 1171
          }
1165 1172

	
1166 1173
          { // int map test
1167 1174
            typedef typename _Digraph::template ArcMap<int> IntArcMap;
1168 1175
            checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, int>,
1169 1176
              IntArcMap >();
1170 1177
          } { // bool map test
1171 1178
            typedef typename _Digraph::template ArcMap<bool> BoolArcMap;
1172 1179
            checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, bool>,
1173 1180
              BoolArcMap >();
1174 1181
          } { // Dummy map test
1175 1182
            typedef typename _Digraph::template ArcMap<Dummy> DummyArcMap;
1176 1183
            checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, Dummy>,
1177 1184
              DummyArcMap >();
1178 1185
          }
1179 1186
        }
1180 1187

	
1181
        _Digraph& digraph;
1188
        const _Digraph& digraph;
1182 1189
      };
1183 1190
    };
1184 1191

	
1185
    /// \brief An empty mappable base bipartite graph class.
1192
    /// \brief Skeleton class for mappable undirected graphs.
1186 1193
    ///
1187
    /// This class provides beside the core graph features
1188
    /// map interface for the graph structure.
1194
    /// This class describes the interface of mappable undirected graphs.
1195
    /// It extends \ref MappableDigraphComponent with the standard graph 
1196
    /// map class for edges (\c EdgeMap).
1189 1197
    /// This concept is part of the Graph concept.
1190 1198
    template <typename BAS = BaseGraphComponent>
1191 1199
    class MappableGraphComponent : public MappableDigraphComponent<BAS>  {
1192 1200
    public:
1193 1201

	
1194 1202
      typedef BAS Base;
1195 1203
      typedef typename Base::Edge Edge;
1196 1204

	
1197 1205
      typedef MappableGraphComponent Graph;
1198 1206

	
1199
      /// \brief ReadWrite map of the edges.
1207
      /// \brief Standard graph map for the edges.
1200 1208
      ///
1201
      /// ReadWrite map of the edges.
1202
      ///
1209
      /// Standard graph map for the edges.
1203 1210
      template <typename V>
1204
      class EdgeMap : public GraphMap<Graph, Edge, V> {
1211
      class EdgeMap : public GraphMap<MappableGraphComponent, Edge, V> {
1205 1212
      public:
1206 1213
        typedef GraphMap<MappableGraphComponent, Edge, V> Parent;
1207 1214

	
1208 1215
        /// \brief Construct a new map.
1209 1216
        ///
1210 1217
        /// Construct a new map for the graph.
1211 1218
        explicit EdgeMap(const MappableGraphComponent& graph)
1212 1219
          : Parent(graph) {}
1213 1220

	
1214 1221
        /// \brief Construct a new map with default value.
1215 1222
        ///
1216
        /// Construct a new map for the graph and initalise the values.
1223
        /// Construct a new map for the graph and initalize the values.
1217 1224
        EdgeMap(const MappableGraphComponent& graph, const V& value)
1218 1225
          : Parent(graph, value) {}
1219 1226

	
1220 1227
      private:
1221 1228
        /// \brief Copy constructor.
1222 1229
        ///
1223 1230
        /// Copy Constructor.
1224 1231
        EdgeMap(const EdgeMap& nm) : Parent(nm) {}
1225 1232

	
1226
        /// \brief Assign operator.
1233
        /// \brief Assignment operator.
1227 1234
        ///
1228
        /// Assign operator.
1235
        /// Assignment operator.
1229 1236
        template <typename CMap>
1230 1237
        EdgeMap& operator=(const CMap&) {
1231 1238
          checkConcept<ReadMap<Edge, V>, CMap>();
1232 1239
          return *this;
1233 1240
        }
1234 1241

	
1235 1242
      };
1236 1243

	
1237 1244

	
1238 1245
      template <typename _Graph>
1239 1246
      struct Constraints {
1240 1247

	
1241 1248
        struct Dummy {
1242 1249
          int value;
1243 1250
          Dummy() : value(0) {}
1244 1251
          Dummy(int _v) : value(_v) {}
1245 1252
        };
1246 1253

	
1247 1254
        void constraints() {
1248
          checkConcept<MappableGraphComponent<Base>, _Graph>();
1255
          checkConcept<MappableDigraphComponent<Base>, _Graph>();
1249 1256

	
1250 1257
          { // int map test
1251 1258
            typedef typename _Graph::template EdgeMap<int> IntEdgeMap;
1252 1259
            checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>,
1253 1260
              IntEdgeMap >();
1254 1261
          } { // bool map test
1255 1262
            typedef typename _Graph::template EdgeMap<bool> BoolEdgeMap;
1256 1263
            checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>,
1257 1264
              BoolEdgeMap >();
1258 1265
          } { // Dummy map test
1259 1266
            typedef typename _Graph::template EdgeMap<Dummy> DummyEdgeMap;
1260 1267
            checkConcept<GraphMap<_Graph, typename _Graph::Edge, Dummy>,
1261 1268
              DummyEdgeMap >();
1262 1269
          }
1263 1270
        }
1264 1271

	
1265
        _Graph& graph;
1272
        const _Graph& graph;
1266 1273
      };
1267 1274
    };
1268 1275

	
1269
    /// \brief An empty extendable digraph class.
1276
    /// \brief Skeleton class for extendable directed graphs.
1270 1277
    ///
1271
    /// This class provides beside the core digraph features digraph
1272
    /// extendable interface for the digraph structure.  The main
1273
    /// difference between the base and this interface is that the
1274
    /// digraph alterations should handled already on this level.
1278
    /// This class describes the interface of extendable directed graphs.
1279
    /// It extends \ref BaseDigraphComponent with functions for adding 
1280
    /// nodes and arcs to the digraph.
1281
    /// This concept requires \ref AlterableDigraphComponent.
1275 1282
    template <typename BAS = BaseDigraphComponent>
1276 1283
    class ExtendableDigraphComponent : public BAS {
1277 1284
    public:
1278 1285
      typedef BAS Base;
1279 1286

	
1280 1287
      typedef typename Base::Node Node;
1281 1288
      typedef typename Base::Arc Arc;
1282 1289

	
1283
      /// \brief Adds a new node to the digraph.
1290
      /// \brief Add a new node to the digraph.
1284 1291
      ///
1285
      /// Adds a new node to the digraph.
1286
      ///
1292
      /// This function adds a new node to the digraph.
1287 1293
      Node addNode() {
1288 1294
        return INVALID;
1289 1295
      }
1290 1296

	
1291
      /// \brief Adds a new arc connects the given two nodes.
1297
      /// \brief Add a new arc connecting the given two nodes.
1292 1298
      ///
1293
      /// Adds a new arc connects the the given two nodes.
1299
      /// This function adds a new arc connecting the given two nodes
1300
      /// of the digraph.
1294 1301
      Arc addArc(const Node&, const Node&) {
1295 1302
        return INVALID;
1296 1303
      }
1297 1304

	
1298 1305
      template <typename _Digraph>
1299 1306
      struct Constraints {
1300 1307
        void constraints() {
1301 1308
          checkConcept<Base, _Digraph>();
1302 1309
          typename _Digraph::Node node_a, node_b;
1303 1310
          node_a = digraph.addNode();
1304 1311
          node_b = digraph.addNode();
1305 1312
          typename _Digraph::Arc arc;
1306 1313
          arc = digraph.addArc(node_a, node_b);
1307 1314
        }
1308 1315

	
1309 1316
        _Digraph& digraph;
1310 1317
      };
1311 1318
    };
1312 1319

	
1313
    /// \brief An empty extendable base undirected graph class.
1320
    /// \brief Skeleton class for extendable undirected graphs.
1314 1321
    ///
1315
    /// This class provides beside the core undirected graph features
1316
    /// core undircted graph extend interface for the graph structure.
1317
    /// The main difference between the base and this interface is
1318
    /// that the graph alterations should handled already on this
1319
    /// level.
1322
    /// This class describes the interface of extendable undirected graphs.
1323
    /// It extends \ref BaseGraphComponent with functions for adding 
1324
    /// nodes and edges to the graph.
1325
    /// This concept requires \ref AlterableGraphComponent.
1320 1326
    template <typename BAS = BaseGraphComponent>
1321 1327
    class ExtendableGraphComponent : public BAS {
1322 1328
    public:
1323 1329

	
1324 1330
      typedef BAS Base;
1325 1331
      typedef typename Base::Node Node;
1326 1332
      typedef typename Base::Edge Edge;
1327 1333

	
1328
      /// \brief Adds a new node to the graph.
1334
      /// \brief Add a new node to the digraph.
1329 1335
      ///
1330
      /// Adds a new node to the graph.
1331
      ///
1336
      /// This function adds a new node to the digraph.
1332 1337
      Node addNode() {
1333 1338
        return INVALID;
1334 1339
      }
1335 1340

	
1336
      /// \brief Adds a new arc connects the given two nodes.
1341
      /// \brief Add a new edge connecting the given two nodes.
1337 1342
      ///
1338
      /// Adds a new arc connects the the given two nodes.
1339
      Edge addArc(const Node&, const Node&) {
1343
      /// This function adds a new edge connecting the given two nodes
1344
      /// of the graph.
1345
      Edge addEdge(const Node&, const Node&) {
1340 1346
        return INVALID;
1341 1347
      }
1342 1348

	
1343 1349
      template <typename _Graph>
1344 1350
      struct Constraints {
1345 1351
        void constraints() {
1346 1352
          checkConcept<Base, _Graph>();
1347 1353
          typename _Graph::Node node_a, node_b;
1348 1354
          node_a = graph.addNode();
1349 1355
          node_b = graph.addNode();
1350 1356
          typename _Graph::Edge edge;
1351 1357
          edge = graph.addEdge(node_a, node_b);
1352 1358
        }
1353 1359

	
1354 1360
        _Graph& graph;
1355 1361
      };
1356 1362
    };
1357 1363

	
1358
    /// \brief An empty erasable digraph class.
1364
    /// \brief Skeleton class for erasable directed graphs.
1359 1365
    ///
1360
    /// This class provides beside the core digraph features core erase
1361
    /// functions for the digraph structure. The main difference between
1362
    /// the base and this interface is that the digraph alterations
1363
    /// should handled already on this level.
1366
    /// This class describes the interface of erasable directed graphs.
1367
    /// It extends \ref BaseDigraphComponent with functions for removing 
1368
    /// nodes and arcs from the digraph.
1369
    /// This concept requires \ref AlterableDigraphComponent.
1364 1370
    template <typename BAS = BaseDigraphComponent>
1365 1371
    class ErasableDigraphComponent : public BAS {
1366 1372
    public:
1367 1373

	
1368 1374
      typedef BAS Base;
1369 1375
      typedef typename Base::Node Node;
1370 1376
      typedef typename Base::Arc Arc;
1371 1377

	
1372 1378
      /// \brief Erase a node from the digraph.
1373 1379
      ///
1374
      /// Erase a node from the digraph. This function should
1375
      /// erase all arcs connecting to the node.
1380
      /// This function erases the given node from the digraph and all arcs 
1381
      /// connected to the node.
1376 1382
      void erase(const Node&) {}
1377 1383

	
1378 1384
      /// \brief Erase an arc from the digraph.
1379 1385
      ///
1380
      /// Erase an arc from the digraph.
1381
      ///
1386
      /// This function erases the given arc from the digraph.
1382 1387
      void erase(const Arc&) {}
1383 1388

	
1384 1389
      template <typename _Digraph>
1385 1390
      struct Constraints {
1386 1391
        void constraints() {
1387 1392
          checkConcept<Base, _Digraph>();
1388
          typename _Digraph::Node node;
1393
          const typename _Digraph::Node node(INVALID);
1389 1394
          digraph.erase(node);
1390
          typename _Digraph::Arc arc;
1395
          const typename _Digraph::Arc arc(INVALID);
1391 1396
          digraph.erase(arc);
1392 1397
        }
1393 1398

	
1394 1399
        _Digraph& digraph;
1395 1400
      };
1396 1401
    };
1397 1402

	
1398
    /// \brief An empty erasable base undirected graph class.
1403
    /// \brief Skeleton class for erasable undirected graphs.
1399 1404
    ///
1400
    /// This class provides beside the core undirected graph features
1401
    /// core erase functions for the undirceted graph structure. The
1402
    /// main difference between the base and this interface is that
1403
    /// the graph alterations should handled already on this level.
1405
    /// This class describes the interface of erasable undirected graphs.
1406
    /// It extends \ref BaseGraphComponent with functions for removing 
1407
    /// nodes and edges from the graph.
1408
    /// This concept requires \ref AlterableGraphComponent.
1404 1409
    template <typename BAS = BaseGraphComponent>
1405 1410
    class ErasableGraphComponent : public BAS {
1406 1411
    public:
1407 1412

	
1408 1413
      typedef BAS Base;
1409 1414
      typedef typename Base::Node Node;
1410 1415
      typedef typename Base::Edge Edge;
1411 1416

	
1412 1417
      /// \brief Erase a node from the graph.
1413 1418
      ///
1414
      /// Erase a node from the graph. This function should erase
1415
      /// arcs connecting to the node.
1419
      /// This function erases the given node from the graph and all edges
1420
      /// connected to the node.
1416 1421
      void erase(const Node&) {}
1417 1422

	
1418
      /// \brief Erase an arc from the graph.
1423
      /// \brief Erase an edge from the digraph.
1419 1424
      ///
1420
      /// Erase an arc from the graph.
1421
      ///
1425
      /// This function erases the given edge from the digraph.
1422 1426
      void erase(const Edge&) {}
1423 1427

	
1424 1428
      template <typename _Graph>
1425 1429
      struct Constraints {
1426 1430
        void constraints() {
1427 1431
          checkConcept<Base, _Graph>();
1428
          typename _Graph::Node node;
1432
          const typename _Graph::Node node(INVALID);
1429 1433
          graph.erase(node);
1430
          typename _Graph::Edge edge;
1434
          const typename _Graph::Edge edge(INVALID);
1431 1435
          graph.erase(edge);
1432 1436
        }
1433 1437

	
1434 1438
        _Graph& graph;
1435 1439
      };
1436 1440
    };
1437 1441

	
1438
    /// \brief An empty clearable base digraph class.
1442
    /// \brief Skeleton class for clearable directed graphs.
1439 1443
    ///
1440
    /// This class provides beside the core digraph features core clear
1441
    /// functions for the digraph structure. The main difference between
1442
    /// the base and this interface is that the digraph alterations
1443
    /// should handled already on this level.
1444
    /// This class describes the interface of clearable directed graphs.
1445
    /// It extends \ref BaseDigraphComponent with a function for clearing
1446
    /// the digraph.
1447
    /// This concept requires \ref AlterableDigraphComponent.
1444 1448
    template <typename BAS = BaseDigraphComponent>
1445 1449
    class ClearableDigraphComponent : public BAS {
1446 1450
    public:
1447 1451

	
1448 1452
      typedef BAS Base;
1449 1453

	
1450 1454
      /// \brief Erase all nodes and arcs from the digraph.
1451 1455
      ///
1452
      /// Erase all nodes and arcs from the digraph.
1453
      ///
1456
      /// This function erases all nodes and arcs from the digraph.
1454 1457
      void clear() {}
1455 1458

	
1456 1459
      template <typename _Digraph>
1457 1460
      struct Constraints {
1458 1461
        void constraints() {
1459 1462
          checkConcept<Base, _Digraph>();
1460 1463
          digraph.clear();
1461 1464
        }
1462 1465

	
1463
        _Digraph digraph;
1466
        _Digraph& digraph;
1464 1467
      };
1465 1468
    };
1466 1469

	
1467
    /// \brief An empty clearable base undirected graph class.
1470
    /// \brief Skeleton class for clearable undirected graphs.
1468 1471
    ///
1469
    /// This class provides beside the core undirected graph features
1470
    /// core clear functions for the undirected graph structure. The
1471
    /// main difference between the base and this interface is that
1472
    /// the graph alterations should handled already on this level.
1472
    /// This class describes the interface of clearable undirected graphs.
1473
    /// It extends \ref BaseGraphComponent with a function for clearing
1474
    /// the graph.
1475
    /// This concept requires \ref AlterableGraphComponent.
1473 1476
    template <typename BAS = BaseGraphComponent>
1474 1477
    class ClearableGraphComponent : public ClearableDigraphComponent<BAS> {
1475 1478
    public:
1476 1479

	
1477 1480
      typedef BAS Base;
1478 1481

	
1482
      /// \brief Erase all nodes and edges from the graph.
1483
      ///
1484
      /// This function erases all nodes and edges from the graph.
1485
      void clear() {}
1486

	
1479 1487
      template <typename _Graph>
1480 1488
      struct Constraints {
1481 1489
        void constraints() {
1482
          checkConcept<ClearableGraphComponent<Base>, _Graph>();
1490
          checkConcept<Base, _Graph>();
1491
          graph.clear();
1483 1492
        }
1484 1493

	
1485
        _Graph graph;
1494
        _Graph& graph;
1486 1495
      };
1487 1496
    };
1488 1497

	
1489 1498
  }
1490 1499

	
1491 1500
}
1492 1501

	
1493 1502
#endif
0 comments (0 inline)