gravatar
kpeter (Peter Kovacs)
kpeter@inf.elte.hu
Various bug fixes and code improvements in adaptors.h (#67) - Fix UndirectorBase::nodeNum(). - Fix UndirectorBase::findEdge(). - Fix OrienterBase::addArc(). - Fix OrienterBase::findArc(). - Improve SplitNodesBase::findArc(). - Add missing notifier() function in UndirectorBase. - Add missing typedefs for maps (conform to the ReferenceMap concept). - Add some useful typedefs for graph adaptors.
0 1 0
default
1 file changed with 71 insertions and 46 deletions:
↑ Collapse diff ↑
Ignore white space 96 line context
... ...
@@ -772,101 +772,104 @@
772 772
    ///
773 773
    /// Returns true if \c n is hidden.
774 774
    ///
775 775
    bool hidden(const Node& n) const { return Parent::hidden(n); }
776 776

	
777 777
    /// \brief Returns true if \c a is hidden.
778 778
    ///
779 779
    /// Returns true if \c a is hidden.
780 780
    ///
781 781
    bool hidden(const Arc& a) const { return Parent::hidden(a); }
782 782

	
783 783
  };
784 784

	
785 785
  /// \brief Just gives back a subdigraph
786 786
  ///
787 787
  /// Just gives back a subdigraph
788 788
  template<typename Digraph, typename NodeFilterMap, typename ArcFilterMap>
789 789
  SubDigraph<const Digraph, NodeFilterMap, ArcFilterMap>
790 790
  subDigraph(const Digraph& digraph, NodeFilterMap& nfm, ArcFilterMap& afm) {
791 791
    return SubDigraph<const Digraph, NodeFilterMap, ArcFilterMap>
792 792
      (digraph, nfm, afm);
793 793
  }
794 794

	
795 795
  template<typename Digraph, typename NodeFilterMap, typename ArcFilterMap>
796 796
  SubDigraph<const Digraph, const NodeFilterMap, ArcFilterMap>
797 797
  subDigraph(const Digraph& digraph,
798 798
             const NodeFilterMap& nfm, ArcFilterMap& afm) {
799 799
    return SubDigraph<const Digraph, const NodeFilterMap, ArcFilterMap>
800 800
      (digraph, nfm, afm);
801 801
  }
802 802

	
803 803
  template<typename Digraph, typename NodeFilterMap, typename ArcFilterMap>
804 804
  SubDigraph<const Digraph, NodeFilterMap, const ArcFilterMap>
805 805
  subDigraph(const Digraph& digraph,
806 806
             NodeFilterMap& nfm, const ArcFilterMap& afm) {
807 807
    return SubDigraph<const Digraph, NodeFilterMap, const ArcFilterMap>
808 808
      (digraph, nfm, afm);
809 809
  }
810 810

	
811 811
  template<typename Digraph, typename NodeFilterMap, typename ArcFilterMap>
812 812
  SubDigraph<const Digraph, const NodeFilterMap, const ArcFilterMap>
813 813
  subDigraph(const Digraph& digraph,
814 814
             const NodeFilterMap& nfm, const ArcFilterMap& afm) {
815 815
    return SubDigraph<const Digraph, const NodeFilterMap,
816 816
      const ArcFilterMap>(digraph, nfm, afm);
817 817
  }
818 818

	
819 819

	
820
  template <typename _Graph, typename NodeFilterMap,
821
            typename EdgeFilterMap, bool _checked = true>
820
  template <typename _Graph, typename _NodeFilterMap,
821
            typename _EdgeFilterMap, bool _checked = true>
822 822
  class SubGraphBase : public GraphAdaptorBase<_Graph> {
823 823
  public:
824 824
    typedef _Graph Graph;
825
    typedef _NodeFilterMap NodeFilterMap;
826
    typedef _EdgeFilterMap EdgeFilterMap;
827

	
825 828
    typedef SubGraphBase Adaptor;
826 829
    typedef GraphAdaptorBase<_Graph> Parent;
827 830
  protected:
828 831

	
829 832
    NodeFilterMap* _node_filter_map;
830 833
    EdgeFilterMap* _edge_filter_map;
831 834

	
832 835
    SubGraphBase()
833 836
      : Parent(), _node_filter_map(0), _edge_filter_map(0) { }
834 837

	
835 838
    void setNodeFilterMap(NodeFilterMap& node_filter_map) {
836 839
      _node_filter_map=&node_filter_map;
837 840
    }
838 841
    void setEdgeFilterMap(EdgeFilterMap& edge_filter_map) {
839 842
      _edge_filter_map=&edge_filter_map;
840 843
    }
841 844

	
842 845
  public:
843 846

	
844 847
    typedef typename Parent::Node Node;
845 848
    typedef typename Parent::Arc Arc;
846 849
    typedef typename Parent::Edge Edge;
847 850

	
848 851
    void first(Node& i) const {
849 852
      Parent::first(i);
850 853
      while (i!=INVALID && !(*_node_filter_map)[i]) Parent::next(i);
851 854
    }
852 855

	
853 856
    void first(Arc& i) const {
854 857
      Parent::first(i);
855 858
      while (i!=INVALID && (!(*_edge_filter_map)[i]
856 859
                            || !(*_node_filter_map)[Parent::source(i)]
857 860
                            || !(*_node_filter_map)[Parent::target(i)]))
858 861
        Parent::next(i);
859 862
    }
860 863

	
861 864
    void first(Edge& i) const {
862 865
      Parent::first(i);
863 866
      while (i!=INVALID && (!(*_edge_filter_map)[i]
864 867
                            || !(*_node_filter_map)[Parent::u(i)]
865 868
                            || !(*_node_filter_map)[Parent::v(i)]))
866 869
        Parent::next(i);
867 870
    }
868 871

	
869 872
    void firstIn(Arc& i, const Node& n) const {
870 873
      Parent::firstIn(i, n);
871 874
      while (i!=INVALID && (!(*_edge_filter_map)[i]
872 875
                            || !(*_node_filter_map)[Parent::source(i)]))
... ...
@@ -1003,101 +1006,104 @@
1003 1006
      typedef SubMapExtender<Adaptor, typename Parent::
1004 1007
                             template ArcMap<Value> > MapParent;
1005 1008

	
1006 1009
      ArcMap(const Adaptor& adaptor)
1007 1010
        : MapParent(adaptor) {}
1008 1011
      ArcMap(const Adaptor& adaptor, const Value& value)
1009 1012
        : MapParent(adaptor, value) {}
1010 1013

	
1011 1014
    private:
1012 1015
      ArcMap& operator=(const ArcMap& cmap) {
1013 1016
        return operator=<ArcMap>(cmap);
1014 1017
      }
1015 1018

	
1016 1019
      template <typename CMap>
1017 1020
      ArcMap& operator=(const CMap& cmap) {
1018 1021
        MapParent::operator=(cmap);
1019 1022
        return *this;
1020 1023
      }
1021 1024
    };
1022 1025

	
1023 1026
    template <typename _Value>
1024 1027
    class EdgeMap : public SubMapExtender<Adaptor,
1025 1028
      typename Parent::template EdgeMap<_Value> > {
1026 1029
    public:
1027 1030
      typedef _Value Value;
1028 1031
      typedef SubMapExtender<Adaptor, typename Parent::
1029 1032
                             template EdgeMap<Value> > MapParent;
1030 1033

	
1031 1034
      EdgeMap(const Adaptor& adaptor)
1032 1035
        : MapParent(adaptor) {}
1033 1036

	
1034 1037
      EdgeMap(const Adaptor& adaptor, const Value& value)
1035 1038
        : MapParent(adaptor, value) {}
1036 1039

	
1037 1040
    private:
1038 1041
      EdgeMap& operator=(const EdgeMap& cmap) {
1039 1042
        return operator=<EdgeMap>(cmap);
1040 1043
      }
1041 1044

	
1042 1045
      template <typename CMap>
1043 1046
      EdgeMap& operator=(const CMap& cmap) {
1044 1047
        MapParent::operator=(cmap);
1045 1048
        return *this;
1046 1049
      }
1047 1050
    };
1048 1051

	
1049 1052
  };
1050 1053

	
1051
  template <typename _Graph, typename NodeFilterMap, typename EdgeFilterMap>
1052
  class SubGraphBase<_Graph, NodeFilterMap, EdgeFilterMap, false>
1054
  template <typename _Graph, typename _NodeFilterMap, typename _EdgeFilterMap>
1055
  class SubGraphBase<_Graph, _NodeFilterMap, _EdgeFilterMap, false>
1053 1056
    : public GraphAdaptorBase<_Graph> {
1054 1057
  public:
1055 1058
    typedef _Graph Graph;
1059
    typedef _NodeFilterMap NodeFilterMap;
1060
    typedef _EdgeFilterMap EdgeFilterMap;
1061

	
1056 1062
    typedef SubGraphBase Adaptor;
1057 1063
    typedef GraphAdaptorBase<_Graph> Parent;
1058 1064
  protected:
1059 1065
    NodeFilterMap* _node_filter_map;
1060 1066
    EdgeFilterMap* _edge_filter_map;
1061 1067
    SubGraphBase() : Parent(),
1062 1068
                     _node_filter_map(0), _edge_filter_map(0) { }
1063 1069

	
1064 1070
    void setNodeFilterMap(NodeFilterMap& node_filter_map) {
1065 1071
      _node_filter_map=&node_filter_map;
1066 1072
    }
1067 1073
    void setEdgeFilterMap(EdgeFilterMap& edge_filter_map) {
1068 1074
      _edge_filter_map=&edge_filter_map;
1069 1075
    }
1070 1076

	
1071 1077
  public:
1072 1078

	
1073 1079
    typedef typename Parent::Node Node;
1074 1080
    typedef typename Parent::Arc Arc;
1075 1081
    typedef typename Parent::Edge Edge;
1076 1082

	
1077 1083
    void first(Node& i) const {
1078 1084
      Parent::first(i);
1079 1085
      while (i!=INVALID && !(*_node_filter_map)[i]) Parent::next(i);
1080 1086
    }
1081 1087

	
1082 1088
    void first(Arc& i) const {
1083 1089
      Parent::first(i);
1084 1090
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::next(i);
1085 1091
    }
1086 1092

	
1087 1093
    void first(Edge& i) const {
1088 1094
      Parent::first(i);
1089 1095
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::next(i);
1090 1096
    }
1091 1097

	
1092 1098
    void firstIn(Arc& i, const Node& n) const {
1093 1099
      Parent::firstIn(i, n);
1094 1100
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::nextIn(i);
1095 1101
    }
1096 1102

	
1097 1103
    void firstOut(Arc& i, const Node& n) const {
1098 1104
      Parent::firstOut(i, n);
1099 1105
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::nextOut(i);
1100 1106
    }
1101 1107

	
1102 1108
    void firstInc(Edge& i, bool& d, const Node& n) const {
1103 1109
      Parent::firstInc(i, d, n);
... ...
@@ -1812,374 +1818,382 @@
1812 1818
    Node v(const Edge& e) const {
1813 1819
      return _digraph->target(e);
1814 1820
    }
1815 1821

	
1816 1822
    Node source(const Arc &a) const {
1817 1823
      return a._forward ? _digraph->source(a) : _digraph->target(a);
1818 1824
    }
1819 1825

	
1820 1826
    Node target(const Arc &a) const {
1821 1827
      return a._forward ? _digraph->target(a) : _digraph->source(a);
1822 1828
    }
1823 1829

	
1824 1830
    static Arc direct(const Edge &e, bool d) {
1825 1831
      return Arc(e, d);
1826 1832
    }
1827 1833
    Arc direct(const Edge &e, const Node& n) const {
1828 1834
      return Arc(e, _digraph->source(e) == n);
1829 1835
    }
1830 1836

	
1831 1837
    static bool direction(const Arc &a) { return a._forward; }
1832 1838

	
1833 1839
    Node nodeFromId(int ix) const { return _digraph->nodeFromId(ix); }
1834 1840
    Arc arcFromId(int ix) const {
1835 1841
      return direct(_digraph->arcFromId(ix >> 1), bool(ix & 1));
1836 1842
    }
1837 1843
    Edge edgeFromId(int ix) const { return _digraph->arcFromId(ix); }
1838 1844

	
1839 1845
    int id(const Node &n) const { return _digraph->id(n); }
1840 1846
    int id(const Arc &a) const {
1841 1847
      return  (_digraph->id(a) << 1) | (a._forward ? 1 : 0);
1842 1848
    }
1843 1849
    int id(const Edge &e) const { return _digraph->id(e); }
1844 1850

	
1845 1851
    int maxNodeId() const { return _digraph->maxNodeId(); }
1846 1852
    int maxArcId() const { return (_digraph->maxArcId() << 1) | 1; }
1847 1853
    int maxEdgeId() const { return _digraph->maxArcId(); }
1848 1854

	
1849 1855
    Node addNode() { return _digraph->addNode(); }
1850 1856
    Edge addEdge(const Node& u, const Node& v) {
1851 1857
      return _digraph->addArc(u, v);
1852 1858
    }
1853 1859

	
1854 1860
    void erase(const Node& i) { _digraph->erase(i); }
1855 1861
    void erase(const Edge& i) { _digraph->erase(i); }
1856 1862

	
1857 1863
    void clear() { _digraph->clear(); }
1858 1864

	
1859 1865
    typedef NodeNumTagIndicator<Digraph> NodeNumTag;
1860
    int nodeNum() const { return 2 * _digraph->arcNum(); }
1866
    int nodeNum() const { return _digraph->nodeNum(); }
1861 1867

	
1862 1868
    typedef ArcNumTagIndicator<Digraph> ArcNumTag;
1863 1869
    int arcNum() const { return 2 * _digraph->arcNum(); }
1864 1870

	
1865 1871
    typedef ArcNumTag EdgeNumTag;
1866 1872
    int edgeNum() const { return _digraph->arcNum(); }
1867 1873

	
1868 1874
    typedef FindArcTagIndicator<Digraph> FindArcTag;
1869 1875
    Arc findArc(Node s, Node t, Arc p = INVALID) const {
1870 1876
      if (p == INVALID) {
1871 1877
        Edge arc = _digraph->findArc(s, t);
1872 1878
        if (arc != INVALID) return direct(arc, true);
1873 1879
        arc = _digraph->findArc(t, s);
1874 1880
        if (arc != INVALID) return direct(arc, false);
1875 1881
      } else if (direction(p)) {
1876 1882
        Edge arc = _digraph->findArc(s, t, p);
1877 1883
        if (arc != INVALID) return direct(arc, true);
1878 1884
        arc = _digraph->findArc(t, s);
1879 1885
        if (arc != INVALID) return direct(arc, false);
1880 1886
      } else {
1881 1887
        Edge arc = _digraph->findArc(t, s, p);
1882 1888
        if (arc != INVALID) return direct(arc, false);
1883 1889
      }
1884 1890
      return INVALID;
1885 1891
    }
1886 1892

	
1887 1893
    typedef FindArcTag FindEdgeTag;
1888 1894
    Edge findEdge(Node s, Node t, Edge p = INVALID) const {
1889 1895
      if (s != t) {
1890 1896
        if (p == INVALID) {
1891 1897
          Edge arc = _digraph->findArc(s, t);
1892 1898
          if (arc != INVALID) return arc;
1893 1899
          arc = _digraph->findArc(t, s);
1894 1900
          if (arc != INVALID) return arc;
1895
        } else if (_digraph->s(p) == s) {
1901
        } else if (_digraph->source(p) == s) {
1896 1902
          Edge arc = _digraph->findArc(s, t, p);
1897 1903
          if (arc != INVALID) return arc;
1898 1904
          arc = _digraph->findArc(t, s);
1899 1905
          if (arc != INVALID) return arc;
1900 1906
        } else {
1901 1907
          Edge arc = _digraph->findArc(t, s, p);
1902 1908
          if (arc != INVALID) return arc;
1903 1909
        }
1904 1910
      } else {
1905 1911
        return _digraph->findArc(s, t, p);
1906 1912
      }
1907 1913
      return INVALID;
1908 1914
    }
1909 1915

	
1910 1916
  private:
1911 1917

	
1912 1918
    template <typename _Value>
1913 1919
    class ArcMapBase {
1914 1920
    private:
1915 1921

	
1916 1922
      typedef typename Digraph::template ArcMap<_Value> MapImpl;
1917 1923

	
1918 1924
    public:
1919 1925

	
1920 1926
      typedef typename MapTraits<MapImpl>::ReferenceMapTag ReferenceMapTag;
1921 1927

	
1922 1928
      typedef _Value Value;
1923 1929
      typedef Arc Key;
1930
      typedef typename MapTraits<MapImpl>::ConstReturnValue ConstReturnValue;
1931
      typedef typename MapTraits<MapImpl>::ReturnValue ReturnValue;
1932
      typedef typename MapTraits<MapImpl>::ConstReturnValue ConstReference;
1933
      typedef typename MapTraits<MapImpl>::ReturnValue Reference;
1924 1934

	
1925 1935
      ArcMapBase(const Adaptor& adaptor) :
1926 1936
        _forward(*adaptor._digraph), _backward(*adaptor._digraph) {}
1927 1937

	
1928 1938
      ArcMapBase(const Adaptor& adaptor, const Value& v)
1929 1939
        : _forward(*adaptor._digraph, v), _backward(*adaptor._digraph, v) {}
1930 1940

	
1931 1941
      void set(const Arc& a, const Value& v) {
1932 1942
        if (direction(a)) {
1933 1943
          _forward.set(a, v);
1934 1944
        } else {
1935 1945
          _backward.set(a, v);
1936 1946
        }
1937 1947
      }
1938 1948

	
1939
      typename MapTraits<MapImpl>::ConstReturnValue
1940
      operator[](const Arc& a) const {
1949
      ConstReturnValue operator[](const Arc& a) const {
1941 1950
        if (direction(a)) {
1942 1951
          return _forward[a];
1943 1952
        } else {
1944 1953
          return _backward[a];
1945 1954
        }
1946 1955
      }
1947 1956

	
1948
      typename MapTraits<MapImpl>::ReturnValue
1949
      operator[](const Arc& a) {
1957
      ReturnValue operator[](const Arc& a) {
1950 1958
        if (direction(a)) {
1951 1959
          return _forward[a];
1952 1960
        } else {
1953 1961
          return _backward[a];
1954 1962
        }
1955 1963
      }
1956 1964

	
1957 1965
    protected:
1958 1966

	
1959 1967
      MapImpl _forward, _backward;
1960 1968

	
1961 1969
    };
1962 1970

	
1963 1971
  public:
1964 1972

	
1965 1973
    template <typename _Value>
1966 1974
    class NodeMap : public Digraph::template NodeMap<_Value> {
1967 1975
    public:
1968 1976

	
1969 1977
      typedef _Value Value;
1970 1978
      typedef typename Digraph::template NodeMap<Value> Parent;
1971 1979

	
1972 1980
      explicit NodeMap(const Adaptor& adaptor)
1973 1981
        : Parent(*adaptor._digraph) {}
1974 1982

	
1975 1983
      NodeMap(const Adaptor& adaptor, const _Value& value)
1976 1984
        : Parent(*adaptor._digraph, value) { }
1977 1985

	
1978 1986
    private:
1979 1987
      NodeMap& operator=(const NodeMap& cmap) {
1980 1988
        return operator=<NodeMap>(cmap);
1981 1989
      }
1982 1990

	
1983 1991
      template <typename CMap>
1984 1992
      NodeMap& operator=(const CMap& cmap) {
1985 1993
        Parent::operator=(cmap);
1986 1994
        return *this;
1987 1995
      }
1988 1996

	
1989 1997
    };
1990 1998

	
1991 1999
    template <typename _Value>
1992 2000
    class ArcMap
1993 2001
      : public SubMapExtender<Adaptor, ArcMapBase<_Value> >
1994 2002
    {
1995 2003
    public:
1996 2004
      typedef _Value Value;
1997 2005
      typedef SubMapExtender<Adaptor, ArcMapBase<Value> > Parent;
1998 2006

	
1999
      ArcMap(const Adaptor& adaptor)
2007
      explicit ArcMap(const Adaptor& adaptor)
2000 2008
        : Parent(adaptor) {}
2001 2009

	
2002 2010
      ArcMap(const Adaptor& adaptor, const Value& value)
2003 2011
        : Parent(adaptor, value) {}
2004 2012

	
2005 2013
    private:
2006 2014
      ArcMap& operator=(const ArcMap& cmap) {
2007 2015
        return operator=<ArcMap>(cmap);
2008 2016
      }
2009 2017

	
2010 2018
      template <typename CMap>
2011 2019
      ArcMap& operator=(const CMap& cmap) {
2012 2020
        Parent::operator=(cmap);
2013 2021
        return *this;
2014 2022
      }
2015 2023
    };
2016 2024

	
2017 2025
    template <typename _Value>
2018 2026
    class EdgeMap : public Digraph::template ArcMap<_Value> {
2019 2027
    public:
2020 2028

	
2021 2029
      typedef _Value Value;
2022 2030
      typedef typename Digraph::template ArcMap<Value> Parent;
2023 2031

	
2024 2032
      explicit EdgeMap(const Adaptor& adaptor)
2025 2033
        : Parent(*adaptor._digraph) {}
2026 2034

	
2027 2035
      EdgeMap(const Adaptor& adaptor, const Value& value)
2028 2036
        : Parent(*adaptor._digraph, value) {}
2029 2037

	
2030 2038
    private:
2031 2039
      EdgeMap& operator=(const EdgeMap& cmap) {
2032 2040
        return operator=<EdgeMap>(cmap);
2033 2041
      }
2034 2042

	
2035 2043
      template <typename CMap>
2036 2044
      EdgeMap& operator=(const CMap& cmap) {
2037 2045
        Parent::operator=(cmap);
2038 2046
        return *this;
2039 2047
      }
2040 2048

	
2041 2049
    };
2042 2050

	
2043 2051
    typedef typename ItemSetTraits<Digraph, Node>::ItemNotifier NodeNotifier;
2044 2052
    NodeNotifier& notifier(Node) const { return _digraph->notifier(Node()); }
2045 2053

	
2054
    typedef typename ItemSetTraits<Digraph, Edge>::ItemNotifier EdgeNotifier;
2055
    EdgeNotifier& notifier(Edge) const { return _digraph->notifier(Edge()); }
2056

	
2046 2057
  protected:
2047 2058

	
2048 2059
    UndirectorBase() : _digraph(0) {}
2049 2060

	
2050 2061
    Digraph* _digraph;
2051 2062

	
2052 2063
    void setDigraph(Digraph& digraph) {
2053 2064
      _digraph = &digraph;
2054 2065
    }
2055 2066

	
2056 2067
  };
2057 2068

	
2058 2069
  /// \ingroup graph_adaptors
2059 2070
  ///
2060 2071
  /// \brief Undirect the graph
2061 2072
  ///
2062 2073
  /// This adaptor makes an undirected graph from a directed
2063 2074
  /// graph. All arcs of the underlying digraph will be showed in the
2064 2075
  /// adaptor as an edge. The Orienter adaptor is conform to the \ref
2065 2076
  /// concepts::Graph "Graph concept".
2066 2077
  ///
2067 2078
  /// \tparam _Digraph It must be conform to the \ref
2068 2079
  /// concepts::Digraph "Digraph concept". The type can be specified
2069 2080
  /// to const.
2070 2081
  template<typename _Digraph>
2071 2082
  class Undirector
2072 2083
    : public GraphAdaptorExtender<UndirectorBase<_Digraph> > {
2073 2084
  public:
2074 2085
    typedef _Digraph Digraph;
2075 2086
    typedef GraphAdaptorExtender<UndirectorBase<Digraph> > Parent;
2076 2087
  protected:
2077 2088
    Undirector() { }
2078 2089
  public:
2079 2090

	
2080 2091
    /// \brief Constructor
2081 2092
    ///
2082 2093
    /// Creates a undirected graph from the given digraph
2083 2094
    Undirector(_Digraph& digraph) {
2084 2095
      setDigraph(digraph);
2085 2096
    }
2086 2097

	
2087 2098
    /// \brief ArcMap combined from two original ArcMap
2088 2099
    ///
2089 2100
    /// This class adapts two original digraph ArcMap to
2090 2101
    /// get an arc map on the undirected graph.
2091 2102
    template <typename _ForwardMap, typename _BackwardMap>
2092 2103
    class CombinedArcMap {
2093 2104
    public:
2094 2105

	
2095 2106
      typedef _ForwardMap ForwardMap;
2096 2107
      typedef _BackwardMap BackwardMap;
2097 2108

	
2098 2109
      typedef typename MapTraits<ForwardMap>::ReferenceMapTag ReferenceMapTag;
2099 2110

	
2100 2111
      typedef typename ForwardMap::Value Value;
2101 2112
      typedef typename Parent::Arc Key;
2102 2113

	
2114
      typedef typename MapTraits<ForwardMap>::ReturnValue ReturnValue;
2115
      typedef typename MapTraits<ForwardMap>::ConstReturnValue ConstReturnValue;
2116
      typedef typename MapTraits<ForwardMap>::ReturnValue Reference;
2117
      typedef typename MapTraits<ForwardMap>::ConstReturnValue ConstReference;
2118

	
2103 2119
      /// \brief Constructor
2104 2120
      ///
2105 2121
      /// Constructor
2106 2122
      CombinedArcMap(ForwardMap& forward, BackwardMap& backward)
2107 2123
        : _forward(&forward), _backward(&backward) {}
2108 2124

	
2109 2125

	
2110 2126
      /// \brief Sets the value associated with a key.
2111 2127
      ///
2112 2128
      /// Sets the value associated with a key.
2113 2129
      void set(const Key& e, const Value& a) {
2114 2130
        if (Parent::direction(e)) {
2115 2131
          _forward->set(e, a);
2116 2132
        } else {
2117 2133
          _backward->set(e, a);
2118 2134
        }
2119 2135
      }
2120 2136

	
2121 2137
      /// \brief Returns the value associated with a key.
2122 2138
      ///
2123 2139
      /// Returns the value associated with a key.
2124
      typename MapTraits<ForwardMap>::ConstReturnValue
2125
      operator[](const Key& e) const {
2140
      ConstReturnValue operator[](const Key& e) const {
2126 2141
        if (Parent::direction(e)) {
2127 2142
          return (*_forward)[e];
2128 2143
        } else {
2129 2144
          return (*_backward)[e];
2130 2145
        }
2131 2146
      }
2132 2147

	
2133 2148
      /// \brief Returns the value associated with a key.
2134 2149
      ///
2135 2150
      /// Returns the value associated with a key.
2136
      typename MapTraits<ForwardMap>::ReturnValue
2137
      operator[](const Key& e) {
2151
      ReturnValue operator[](const Key& e) {
2138 2152
        if (Parent::direction(e)) {
2139 2153
          return (*_forward)[e];
2140 2154
        } else {
2141 2155
          return (*_backward)[e];
2142 2156
        }
2143 2157
      }
2144 2158

	
2145 2159
    protected:
2146 2160

	
2147 2161
      ForwardMap* _forward;
2148 2162
      BackwardMap* _backward;
2149 2163

	
2150 2164
    };
2151 2165

	
2152 2166
    /// \brief Just gives back a combined arc map
2153 2167
    ///
2154 2168
    /// Just gives back a combined arc map
2155 2169
    template <typename ForwardMap, typename BackwardMap>
2156 2170
    static CombinedArcMap<ForwardMap, BackwardMap>
2157 2171
    combinedArcMap(ForwardMap& forward, BackwardMap& backward) {
2158 2172
      return CombinedArcMap<ForwardMap, BackwardMap>(forward, backward);
2159 2173
    }
2160 2174

	
2161 2175
    template <typename ForwardMap, typename BackwardMap>
2162 2176
    static CombinedArcMap<const ForwardMap, BackwardMap>
2163 2177
    combinedArcMap(const ForwardMap& forward, BackwardMap& backward) {
2164 2178
      return CombinedArcMap<const ForwardMap,
2165 2179
        BackwardMap>(forward, backward);
2166 2180
    }
2167 2181

	
2168 2182
    template <typename ForwardMap, typename BackwardMap>
2169 2183
    static CombinedArcMap<ForwardMap, const BackwardMap>
2170 2184
    combinedArcMap(ForwardMap& forward, const BackwardMap& backward) {
2171 2185
      return CombinedArcMap<ForwardMap,
2172 2186
        const BackwardMap>(forward, backward);
2173 2187
    }
2174 2188

	
2175 2189
    template <typename ForwardMap, typename BackwardMap>
2176 2190
    static CombinedArcMap<const ForwardMap, const BackwardMap>
2177 2191
    combinedArcMap(const ForwardMap& forward, const BackwardMap& backward) {
2178 2192
      return CombinedArcMap<const ForwardMap,
2179 2193
        const BackwardMap>(forward, backward);
2180 2194
    }
2181 2195

	
2182 2196
  };
2183 2197

	
2184 2198
  /// \brief Just gives back an undirected view of the given digraph
2185 2199
  ///
... ...
@@ -2201,119 +2215,110 @@
2201 2215
    typedef typename Graph::Edge Arc;
2202 2216

	
2203 2217
    void reverseArc(const Arc& arc) {
2204 2218
      _direction->set(arc, !(*_direction)[arc]);
2205 2219
    }
2206 2220

	
2207 2221
    void first(Node& i) const { _graph->first(i); }
2208 2222
    void first(Arc& i) const { _graph->first(i); }
2209 2223
    void firstIn(Arc& i, const Node& n) const {
2210 2224
      bool d = true;
2211 2225
      _graph->firstInc(i, d, n);
2212 2226
      while (i != INVALID && d == (*_direction)[i]) _graph->nextInc(i, d);
2213 2227
    }
2214 2228
    void firstOut(Arc& i, const Node& n ) const {
2215 2229
      bool d = true;
2216 2230
      _graph->firstInc(i, d, n);
2217 2231
      while (i != INVALID && d != (*_direction)[i]) _graph->nextInc(i, d);
2218 2232
    }
2219 2233

	
2220 2234
    void next(Node& i) const { _graph->next(i); }
2221 2235
    void next(Arc& i) const { _graph->next(i); }
2222 2236
    void nextIn(Arc& i) const {
2223 2237
      bool d = !(*_direction)[i];
2224 2238
      _graph->nextInc(i, d);
2225 2239
      while (i != INVALID && d == (*_direction)[i]) _graph->nextInc(i, d);
2226 2240
    }
2227 2241
    void nextOut(Arc& i) const {
2228 2242
      bool d = (*_direction)[i];
2229 2243
      _graph->nextInc(i, d);
2230 2244
      while (i != INVALID && d != (*_direction)[i]) _graph->nextInc(i, d);
2231 2245
    }
2232 2246

	
2233 2247
    Node source(const Arc& e) const {
2234 2248
      return (*_direction)[e] ? _graph->u(e) : _graph->v(e);
2235 2249
    }
2236 2250
    Node target(const Arc& e) const {
2237 2251
      return (*_direction)[e] ? _graph->v(e) : _graph->u(e);
2238 2252
    }
2239 2253

	
2240 2254
    typedef NodeNumTagIndicator<Graph> NodeNumTag;
2241 2255
    int nodeNum() const { return _graph->nodeNum(); }
2242 2256

	
2243 2257
    typedef EdgeNumTagIndicator<Graph> ArcNumTag;
2244 2258
    int arcNum() const { return _graph->edgeNum(); }
2245 2259

	
2246 2260
    typedef FindEdgeTagIndicator<Graph> FindArcTag;
2247 2261
    Arc findArc(const Node& u, const Node& v,
2248 2262
                const Arc& prev = INVALID) const {
2249
      Arc arc = prev;
2250
      bool d = arc == INVALID ? true : (*_direction)[arc];
2251
      if (d) {
2263
      Arc arc = _graph->findEdge(u, v, prev);
2264
      while (arc != INVALID && source(arc) != u) {
2252 2265
        arc = _graph->findEdge(u, v, arc);
2253
        while (arc != INVALID && !(*_direction)[arc]) {
2254
          _graph->findEdge(u, v, arc);
2255
        }
2256
        if (arc != INVALID) return arc;
2257
      }
2258
      _graph->findEdge(v, u, arc);
2259
      while (arc != INVALID && (*_direction)[arc]) {
2260
        _graph->findEdge(u, v, arc);
2261 2266
      }
2262 2267
      return arc;
2263 2268
    }
2264 2269

	
2265 2270
    Node addNode() {
2266 2271
      return Node(_graph->addNode());
2267 2272
    }
2268 2273

	
2269 2274
    Arc addArc(const Node& u, const Node& v) {
2270
      Arc arc = _graph->addArc(u, v);
2271
      _direction->set(arc, _graph->source(arc) == u);
2275
      Arc arc = _graph->addEdge(u, v);
2276
      _direction->set(arc, _graph->u(arc) == u);
2272 2277
      return arc;
2273 2278
    }
2274 2279

	
2275 2280
    void erase(const Node& i) { _graph->erase(i); }
2276 2281
    void erase(const Arc& i) { _graph->erase(i); }
2277 2282

	
2278 2283
    void clear() { _graph->clear(); }
2279 2284

	
2280 2285
    int id(const Node& v) const { return _graph->id(v); }
2281 2286
    int id(const Arc& e) const { return _graph->id(e); }
2282 2287

	
2283 2288
    Node nodeFromId(int idx) const { return _graph->nodeFromId(idx); }
2284 2289
    Arc arcFromId(int idx) const { return _graph->edgeFromId(idx); }
2285 2290

	
2286 2291
    int maxNodeId() const { return _graph->maxNodeId(); }
2287 2292
    int maxArcId() const { return _graph->maxEdgeId(); }
2288 2293

	
2289 2294
    typedef typename ItemSetTraits<Graph, Node>::ItemNotifier NodeNotifier;
2290 2295
    NodeNotifier& notifier(Node) const { return _graph->notifier(Node()); }
2291 2296

	
2292 2297
    typedef typename ItemSetTraits<Graph, Arc>::ItemNotifier ArcNotifier;
2293 2298
    ArcNotifier& notifier(Arc) const { return _graph->notifier(Arc()); }
2294 2299

	
2295 2300
    template <typename _Value>
2296 2301
    class NodeMap : public _Graph::template NodeMap<_Value> {
2297 2302
    public:
2298 2303

	
2299 2304
      typedef typename _Graph::template NodeMap<_Value> Parent;
2300 2305

	
2301 2306
      explicit NodeMap(const OrienterBase& adapter)
2302 2307
        : Parent(*adapter._graph) {}
2303 2308

	
2304 2309
      NodeMap(const OrienterBase& adapter, const _Value& value)
2305 2310
        : Parent(*adapter._graph, value) {}
2306 2311

	
2307 2312
    private:
2308 2313
      NodeMap& operator=(const NodeMap& cmap) {
2309 2314
        return operator=<NodeMap>(cmap);
2310 2315
      }
2311 2316

	
2312 2317
      template <typename CMap>
2313 2318
      NodeMap& operator=(const CMap& cmap) {
2314 2319
        Parent::operator=(cmap);
2315 2320
        return *this;
2316 2321
      }
2317 2322

	
2318 2323
    };
2319 2324

	
... ...
@@ -2867,182 +2872,185 @@
2867 2872
                      (_digraph->maxArcId() << 1) | 1);
2868 2873
    }
2869 2874

	
2870 2875
    static bool inNode(const Node& n) {
2871 2876
      return n._in;
2872 2877
    }
2873 2878

	
2874 2879
    static bool outNode(const Node& n) {
2875 2880
      return !n._in;
2876 2881
    }
2877 2882

	
2878 2883
    static bool origArc(const Arc& e) {
2879 2884
      return e._item.firstState();
2880 2885
    }
2881 2886

	
2882 2887
    static bool bindArc(const Arc& e) {
2883 2888
      return e._item.secondState();
2884 2889
    }
2885 2890

	
2886 2891
    static Node inNode(const DigraphNode& n) {
2887 2892
      return Node(n, true);
2888 2893
    }
2889 2894

	
2890 2895
    static Node outNode(const DigraphNode& n) {
2891 2896
      return Node(n, false);
2892 2897
    }
2893 2898

	
2894 2899
    static Arc arc(const DigraphNode& n) {
2895 2900
      return Arc(n);
2896 2901
    }
2897 2902

	
2898 2903
    static Arc arc(const DigraphArc& e) {
2899 2904
      return Arc(e);
2900 2905
    }
2901 2906

	
2902 2907
    typedef True NodeNumTag;
2903 2908
    int nodeNum() const {
2904 2909
      return  2 * countNodes(*_digraph);
2905 2910
    }
2906 2911

	
2907 2912
    typedef True ArcNumTag;
2908 2913
    int arcNum() const {
2909 2914
      return countArcs(*_digraph) + countNodes(*_digraph);
2910 2915
    }
2911 2916

	
2912 2917
    typedef True FindArcTag;
2913 2918
    Arc findArc(const Node& u, const Node& v,
2914 2919
                const Arc& prev = INVALID) const {
2915
      if (inNode(u)) {
2916
        if (outNode(v)) {
2917
          if (static_cast<const DigraphNode&>(u) ==
2918
              static_cast<const DigraphNode&>(v) && prev == INVALID) {
2919
            return Arc(u);
2920
          }
2920
      if (inNode(u) && outNode(v)) {
2921
        if (static_cast<const DigraphNode&>(u) ==
2922
            static_cast<const DigraphNode&>(v) && prev == INVALID) {
2923
          return Arc(u);
2921 2924
        }
2922
      } else {
2923
        if (inNode(v)) {
2924
          return Arc(::lemon::findArc(*_digraph, u, v, prev));
2925
        }
2925
      }
2926
      else if (outNode(u) && inNode(v)) {
2927
        return Arc(::lemon::findArc(*_digraph, u, v, prev));
2926 2928
      }
2927 2929
      return INVALID;
2928 2930
    }
2929 2931

	
2930 2932
  private:
2931 2933

	
2932 2934
    template <typename _Value>
2933 2935
    class NodeMapBase
2934 2936
      : public MapTraits<typename Parent::template NodeMap<_Value> > {
2935 2937
      typedef typename Parent::template NodeMap<_Value> NodeImpl;
2936 2938
    public:
2937 2939
      typedef Node Key;
2938 2940
      typedef _Value Value;
2941
      typedef typename MapTraits<NodeImpl>::ReferenceMapTag ReferenceMapTag;
2942
      typedef typename MapTraits<NodeImpl>::ReturnValue ReturnValue;
2943
      typedef typename MapTraits<NodeImpl>::ConstReturnValue ConstReturnValue;
2944
      typedef typename MapTraits<NodeImpl>::ReturnValue Reference;
2945
      typedef typename MapTraits<NodeImpl>::ConstReturnValue ConstReference;
2939 2946

	
2940 2947
      NodeMapBase(const Adaptor& adaptor)
2941 2948
        : _in_map(*adaptor._digraph), _out_map(*adaptor._digraph) {}
2942 2949
      NodeMapBase(const Adaptor& adaptor, const Value& value)
2943 2950
        : _in_map(*adaptor._digraph, value),
2944 2951
          _out_map(*adaptor._digraph, value) {}
2945 2952

	
2946 2953
      void set(const Node& key, const Value& val) {
2947 2954
        if (Adaptor::inNode(key)) { _in_map.set(key, val); }
2948 2955
        else {_out_map.set(key, val); }
2949 2956
      }
2950 2957

	
2951
      typename MapTraits<NodeImpl>::ReturnValue
2952
      operator[](const Node& key) {
2958
      ReturnValue operator[](const Node& key) {
2953 2959
        if (Adaptor::inNode(key)) { return _in_map[key]; }
2954 2960
        else { return _out_map[key]; }
2955 2961
      }
2956 2962

	
2957
      typename MapTraits<NodeImpl>::ConstReturnValue
2958
      operator[](const Node& key) const {
2963
      ConstReturnValue operator[](const Node& key) const {
2959 2964
        if (Adaptor::inNode(key)) { return _in_map[key]; }
2960 2965
        else { return _out_map[key]; }
2961 2966
      }
2962 2967

	
2963 2968
    private:
2964 2969
      NodeImpl _in_map, _out_map;
2965 2970
    };
2966 2971

	
2967 2972
    template <typename _Value>
2968 2973
    class ArcMapBase
2969 2974
      : public MapTraits<typename Parent::template ArcMap<_Value> > {
2970 2975
      typedef typename Parent::template ArcMap<_Value> ArcImpl;
2971 2976
      typedef typename Parent::template NodeMap<_Value> NodeImpl;
2972 2977
    public:
2973 2978
      typedef Arc Key;
2974 2979
      typedef _Value Value;
2980
      typedef typename MapTraits<ArcImpl>::ReferenceMapTag ReferenceMapTag;
2981
      typedef typename MapTraits<ArcImpl>::ReturnValue ReturnValue;
2982
      typedef typename MapTraits<ArcImpl>::ConstReturnValue ConstReturnValue;
2983
      typedef typename MapTraits<ArcImpl>::ReturnValue Reference;
2984
      typedef typename MapTraits<ArcImpl>::ConstReturnValue ConstReference;
2975 2985

	
2976 2986
      ArcMapBase(const Adaptor& adaptor)
2977 2987
        : _arc_map(*adaptor._digraph), _node_map(*adaptor._digraph) {}
2978 2988
      ArcMapBase(const Adaptor& adaptor, const Value& value)
2979 2989
        : _arc_map(*adaptor._digraph, value),
2980 2990
          _node_map(*adaptor._digraph, value) {}
2981 2991

	
2982 2992
      void set(const Arc& key, const Value& val) {
2983 2993
        if (Adaptor::origArc(key)) {
2984 2994
          _arc_map.set(key._item.first(), val);
2985 2995
        } else {
2986 2996
          _node_map.set(key._item.second(), val);
2987 2997
        }
2988 2998
      }
2989 2999

	
2990
      typename MapTraits<ArcImpl>::ReturnValue
2991
      operator[](const Arc& key) {
3000
      ReturnValue operator[](const Arc& key) {
2992 3001
        if (Adaptor::origArc(key)) {
2993 3002
          return _arc_map[key._item.first()];
2994 3003
        } else {
2995 3004
          return _node_map[key._item.second()];
2996 3005
        }
2997 3006
      }
2998 3007

	
2999
      typename MapTraits<ArcImpl>::ConstReturnValue
3000
      operator[](const Arc& key) const {
3008
      ConstReturnValue operator[](const Arc& key) const {
3001 3009
        if (Adaptor::origArc(key)) {
3002 3010
          return _arc_map[key._item.first()];
3003 3011
        } else {
3004 3012
          return _node_map[key._item.second()];
3005 3013
        }
3006 3014
      }
3007 3015

	
3008 3016
    private:
3009 3017
      ArcImpl _arc_map;
3010 3018
      NodeImpl _node_map;
3011 3019
    };
3012 3020

	
3013 3021
  public:
3014 3022

	
3015 3023
    template <typename _Value>
3016 3024
    class NodeMap
3017 3025
      : public SubMapExtender<Adaptor, NodeMapBase<_Value> >
3018 3026
    {
3019 3027
    public:
3020 3028
      typedef _Value Value;
3021 3029
      typedef SubMapExtender<Adaptor, NodeMapBase<Value> > Parent;
3022 3030

	
3023 3031
      NodeMap(const Adaptor& adaptor)
3024 3032
        : Parent(adaptor) {}
3025 3033

	
3026 3034
      NodeMap(const Adaptor& adaptor, const Value& value)
3027 3035
        : Parent(adaptor, value) {}
3028 3036

	
3029 3037
    private:
3030 3038
      NodeMap& operator=(const NodeMap& cmap) {
3031 3039
        return operator=<NodeMap>(cmap);
3032 3040
      }
3033 3041

	
3034 3042
      template <typename CMap>
3035 3043
      NodeMap& operator=(const CMap& cmap) {
3036 3044
        Parent::operator=(cmap);
3037 3045
        return *this;
3038 3046
      }
3039 3047
    };
3040 3048

	
3041 3049
    template <typename _Value>
3042 3050
    class ArcMap
3043 3051
      : public SubMapExtender<Adaptor, ArcMapBase<_Value> >
3044 3052
    {
3045 3053
    public:
3046 3054
      typedef _Value Value;
3047 3055
      typedef SubMapExtender<Adaptor, ArcMapBase<Value> > Parent;
3048 3056

	
... ...
@@ -3139,182 +3147,199 @@
3139 3147
    }
3140 3148

	
3141 3149
    /// \brief Returns true when the arc binds an in-node and an out-node.
3142 3150
    ///
3143 3151
    /// Returns true when the arc binds an in-node and an out-node.
3144 3152
    static bool bindArc(const Arc& a) {
3145 3153
      return Parent::bindArc(a);
3146 3154
    }
3147 3155

	
3148 3156
    /// \brief Gives back the in-node created from the \c node.
3149 3157
    ///
3150 3158
    /// Gives back the in-node created from the \c node.
3151 3159
    static Node inNode(const DigraphNode& n) {
3152 3160
      return Parent::inNode(n);
3153 3161
    }
3154 3162

	
3155 3163
    /// \brief Gives back the out-node created from the \c node.
3156 3164
    ///
3157 3165
    /// Gives back the out-node created from the \c node.
3158 3166
    static Node outNode(const DigraphNode& n) {
3159 3167
      return Parent::outNode(n);
3160 3168
    }
3161 3169

	
3162 3170
    /// \brief Gives back the arc binds the two part of the node.
3163 3171
    ///
3164 3172
    /// Gives back the arc binds the two part of the node.
3165 3173
    static Arc arc(const DigraphNode& n) {
3166 3174
      return Parent::arc(n);
3167 3175
    }
3168 3176

	
3169 3177
    /// \brief Gives back the arc of the original arc.
3170 3178
    ///
3171 3179
    /// Gives back the arc of the original arc.
3172 3180
    static Arc arc(const DigraphArc& a) {
3173 3181
      return Parent::arc(a);
3174 3182
    }
3175 3183

	
3176 3184
    /// \brief NodeMap combined from two original NodeMap
3177 3185
    ///
3178 3186
    /// This class adapt two of the original digraph NodeMap to
3179 3187
    /// get a node map on the adapted digraph.
3180 3188
    template <typename InNodeMap, typename OutNodeMap>
3181 3189
    class CombinedNodeMap {
3182 3190
    public:
3183 3191

	
3184 3192
      typedef Node Key;
3185 3193
      typedef typename InNodeMap::Value Value;
3186 3194

	
3195
      typedef typename MapTraits<InNodeMap>::ReferenceMapTag ReferenceMapTag;
3196
      typedef typename MapTraits<InNodeMap>::ReturnValue ReturnValue;
3197
      typedef typename MapTraits<InNodeMap>::ConstReturnValue ConstReturnValue;
3198
      typedef typename MapTraits<InNodeMap>::ReturnValue Reference;
3199
      typedef typename MapTraits<InNodeMap>::ConstReturnValue ConstReference;
3200

	
3187 3201
      /// \brief Constructor
3188 3202
      ///
3189 3203
      /// Constructor.
3190 3204
      CombinedNodeMap(InNodeMap& in_map, OutNodeMap& out_map)
3191 3205
        : _in_map(in_map), _out_map(out_map) {}
3192 3206

	
3193 3207
      /// \brief The subscript operator.
3194 3208
      ///
3195 3209
      /// The subscript operator.
3196 3210
      Value& operator[](const Key& key) {
3197 3211
        if (Parent::inNode(key)) {
3198 3212
          return _in_map[key];
3199 3213
        } else {
3200 3214
          return _out_map[key];
3201 3215
        }
3202 3216
      }
3203 3217

	
3204 3218
      /// \brief The const subscript operator.
3205 3219
      ///
3206 3220
      /// The const subscript operator.
3207 3221
      Value operator[](const Key& key) const {
3208 3222
        if (Parent::inNode(key)) {
3209 3223
          return _in_map[key];
3210 3224
        } else {
3211 3225
          return _out_map[key];
3212 3226
        }
3213 3227
      }
3214 3228

	
3215 3229
      /// \brief The setter function of the map.
3216 3230
      ///
3217 3231
      /// The setter function of the map.
3218 3232
      void set(const Key& key, const Value& value) {
3219 3233
        if (Parent::inNode(key)) {
3220 3234
          _in_map.set(key, value);
3221 3235
        } else {
3222 3236
          _out_map.set(key, value);
3223 3237
        }
3224 3238
      }
3225 3239

	
3226 3240
    private:
3227 3241

	
3228 3242
      InNodeMap& _in_map;
3229 3243
      OutNodeMap& _out_map;
3230 3244

	
3231 3245
    };
3232 3246

	
3233 3247

	
3234 3248
    /// \brief Just gives back a combined node map
3235 3249
    ///
3236 3250
    /// Just gives back a combined node map
3237 3251
    template <typename InNodeMap, typename OutNodeMap>
3238 3252
    static CombinedNodeMap<InNodeMap, OutNodeMap>
3239 3253
    combinedNodeMap(InNodeMap& in_map, OutNodeMap& out_map) {
3240 3254
      return CombinedNodeMap<InNodeMap, OutNodeMap>(in_map, out_map);
3241 3255
    }
3242 3256

	
3243 3257
    template <typename InNodeMap, typename OutNodeMap>
3244 3258
    static CombinedNodeMap<const InNodeMap, OutNodeMap>
3245 3259
    combinedNodeMap(const InNodeMap& in_map, OutNodeMap& out_map) {
3246 3260
      return CombinedNodeMap<const InNodeMap, OutNodeMap>(in_map, out_map);
3247 3261
    }
3248 3262

	
3249 3263
    template <typename InNodeMap, typename OutNodeMap>
3250 3264
    static CombinedNodeMap<InNodeMap, const OutNodeMap>
3251 3265
    combinedNodeMap(InNodeMap& in_map, const OutNodeMap& out_map) {
3252 3266
      return CombinedNodeMap<InNodeMap, const OutNodeMap>(in_map, out_map);
3253 3267
    }
3254 3268

	
3255 3269
    template <typename InNodeMap, typename OutNodeMap>
3256 3270
    static CombinedNodeMap<const InNodeMap, const OutNodeMap>
3257 3271
    combinedNodeMap(const InNodeMap& in_map, const OutNodeMap& out_map) {
3258 3272
      return CombinedNodeMap<const InNodeMap,
3259 3273
        const OutNodeMap>(in_map, out_map);
3260 3274
    }
3261 3275

	
3262 3276
    /// \brief ArcMap combined from an original ArcMap and a NodeMap
3263 3277
    ///
3264 3278
    /// This class adapt an original ArcMap and a NodeMap to get an
3265 3279
    /// arc map on the adapted digraph
3266 3280
    template <typename DigraphArcMap, typename DigraphNodeMap>
3267 3281
    class CombinedArcMap {
3268 3282
    public:
3269 3283

	
3270 3284
      typedef Arc Key;
3271 3285
      typedef typename DigraphArcMap::Value Value;
3272 3286

	
3287
      typedef typename MapTraits<DigraphArcMap>::ReferenceMapTag
3288
        ReferenceMapTag;
3289
      typedef typename MapTraits<DigraphArcMap>::ReturnValue
3290
        ReturnValue;
3291
      typedef typename MapTraits<DigraphArcMap>::ConstReturnValue
3292
        ConstReturnValue;
3293
      typedef typename MapTraits<DigraphArcMap>::ReturnValue
3294
        Reference;
3295
      typedef typename MapTraits<DigraphArcMap>::ConstReturnValue
3296
        ConstReference;
3297

	
3273 3298
      /// \brief Constructor
3274 3299
      ///
3275 3300
      /// Constructor.
3276 3301
      CombinedArcMap(DigraphArcMap& arc_map, DigraphNodeMap& node_map)
3277 3302
        : _arc_map(arc_map), _node_map(node_map) {}
3278 3303

	
3279 3304
      /// \brief The subscript operator.
3280 3305
      ///
3281 3306
      /// The subscript operator.
3282 3307
      void set(const Arc& arc, const Value& val) {
3283 3308
        if (Parent::origArc(arc)) {
3284 3309
          _arc_map.set(arc, val);
3285 3310
        } else {
3286 3311
          _node_map.set(arc, val);
3287 3312
        }
3288 3313
      }
3289 3314

	
3290 3315
      /// \brief The const subscript operator.
3291 3316
      ///
3292 3317
      /// The const subscript operator.
3293 3318
      Value operator[](const Key& arc) const {
3294 3319
        if (Parent::origArc(arc)) {
3295 3320
          return _arc_map[arc];
3296 3321
        } else {
3297 3322
          return _node_map[arc];
3298 3323
        }
3299 3324
      }
3300 3325

	
3301 3326
      /// \brief The const subscript operator.
3302 3327
      ///
3303 3328
      /// The const subscript operator.
3304 3329
      Value& operator[](const Key& arc) {
3305 3330
        if (Parent::origArc(arc)) {
3306 3331
          return _arc_map[arc];
3307 3332
        } else {
3308 3333
          return _node_map[arc];
3309 3334
        }
3310 3335
      }
3311 3336

	
3312 3337
    private:
3313 3338
      DigraphArcMap& _arc_map;
3314 3339
      DigraphNodeMap& _node_map;
3315 3340
    };
3316 3341

	
3317 3342
    /// \brief Just gives back a combined arc map
3318 3343
    ///
3319 3344
    /// Just gives back a combined arc map
3320 3345
    template <typename DigraphArcMap, typename DigraphNodeMap>
0 comments (0 inline)