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 ↑
Show white space 6 line context
... ...
@@ -819,4 +819,4 @@
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> {
... ...
@@ -824,2 +824,5 @@
824 824
    typedef _Graph Graph;
825
    typedef _NodeFilterMap NodeFilterMap;
826
    typedef _EdgeFilterMap EdgeFilterMap;
827

	
825 828
    typedef SubGraphBase Adaptor;
... ...
@@ -1050,4 +1053,4 @@
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> {
... ...
@@ -1055,2 +1058,5 @@
1055 1058
    typedef _Graph Graph;
1059
    typedef _NodeFilterMap NodeFilterMap;
1060
    typedef _EdgeFilterMap EdgeFilterMap;
1061

	
1056 1062
    typedef SubGraphBase Adaptor;
... ...
@@ -1859,3 +1865,3 @@
1859 1865
    typedef NodeNumTagIndicator<Digraph> NodeNumTag;
1860
    int nodeNum() const { return 2 * _digraph->arcNum(); }
1866
    int nodeNum() const { return _digraph->nodeNum(); }
1861 1867

	
... ...
@@ -1894,3 +1900,3 @@
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);
... ...
@@ -1923,2 +1929,6 @@
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

	
... ...
@@ -1938,4 +1948,3 @@
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)) {
... ...
@@ -1947,4 +1956,3 @@
1947 1956

	
1948
      typename MapTraits<MapImpl>::ReturnValue
1949
      operator[](const Arc& a) {
1957
      ReturnValue operator[](const Arc& a) {
1950 1958
        if (direction(a)) {
... ...
@@ -1998,3 +2006,3 @@
1998 2006

	
1999
      ArcMap(const Adaptor& adaptor)
2007
      explicit ArcMap(const Adaptor& adaptor)
2000 2008
        : Parent(adaptor) {}
... ...
@@ -2045,2 +2053,5 @@
2045 2053

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

	
2046 2057
  protected:
... ...
@@ -2102,2 +2113,7 @@
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
... ...
@@ -2123,4 +2139,3 @@
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)) {
... ...
@@ -2135,4 +2150,3 @@
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)) {
... ...
@@ -2248,14 +2262,5 @@
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
      }
... ...
@@ -2269,4 +2274,4 @@
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;
... ...
@@ -2914,13 +2919,10 @@
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
      }
... ...
@@ -2938,2 +2940,7 @@
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

	
... ...
@@ -2950,4 +2957,3 @@
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]; }
... ...
@@ -2956,4 +2962,3 @@
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]; }
... ...
@@ -2974,2 +2979,7 @@
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

	
... ...
@@ -2989,4 +2999,3 @@
2989 2999

	
2990
      typename MapTraits<ArcImpl>::ReturnValue
2991
      operator[](const Arc& key) {
3000
      ReturnValue operator[](const Arc& key) {
2992 3001
        if (Adaptor::origArc(key)) {
... ...
@@ -2998,4 +3007,3 @@
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)) {
... ...
@@ -3186,2 +3194,8 @@
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
... ...
@@ -3272,2 +3286,13 @@
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
0 comments (0 inline)