gravatar
deba@inf.elte.hu
deba@inf.elte.hu
Fix PredMatrixMapPath::empty() (#366)
0 1 0
default
1 file changed with 1 insertions and 1 deletions:
↑ Collapse diff ↑
Ignore white space 96 line context
... ...
@@ -75,97 +75,97 @@
75 75
      bool operator!=(const RevArcIt& e) const {
76 76
        return current != e.current;
77 77
      }
78 78

	
79 79
      bool operator<(const RevArcIt& e) const {
80 80
        return current < e.current;
81 81
      }
82 82

	
83 83
    private:
84 84
      const PredMapPath* path;
85 85
      typename Digraph::Node current;
86 86
    };
87 87

	
88 88
  private:
89 89
    const Digraph& digraph;
90 90
    const PredMap& predMap;
91 91
    typename Digraph::Node target;
92 92
  };
93 93

	
94 94

	
95 95
  template <typename _Digraph, typename _PredMatrixMap>
96 96
  class PredMatrixMapPath {
97 97
  public:
98 98
    typedef True RevPathTag;
99 99

	
100 100
    typedef _Digraph Digraph;
101 101
    typedef typename Digraph::Arc Arc;
102 102
    typedef _PredMatrixMap PredMatrixMap;
103 103

	
104 104
    PredMatrixMapPath(const Digraph& _digraph,
105 105
                      const PredMatrixMap& _predMatrixMap,
106 106
                      typename Digraph::Node _source,
107 107
                      typename Digraph::Node _target)
108 108
      : digraph(_digraph), predMatrixMap(_predMatrixMap),
109 109
        source(_source), target(_target) {}
110 110

	
111 111
    int length() const {
112 112
      int len = 0;
113 113
      typename Digraph::Node node = target;
114 114
      typename Digraph::Arc arc;
115 115
      while ((arc = predMatrixMap(source, node)) != INVALID) {
116 116
        node = digraph.source(arc);
117 117
        ++len;
118 118
      }
119 119
      return len;
120 120
    }
121 121

	
122 122
    bool empty() const {
123
      return source != target;
123
      return predMatrixMap(source, target) == INVALID;
124 124
    }
125 125

	
126 126
    class RevArcIt {
127 127
    public:
128 128
      RevArcIt() {}
129 129
      RevArcIt(Invalid) : path(0), current(INVALID) {}
130 130
      RevArcIt(const PredMatrixMapPath& _path)
131 131
        : path(&_path), current(_path.target) {
132 132
        if (path->predMatrixMap(path->source, current) == INVALID)
133 133
          current = INVALID;
134 134
      }
135 135

	
136 136
      operator const typename Digraph::Arc() const {
137 137
        return path->predMatrixMap(path->source, current);
138 138
      }
139 139

	
140 140
      RevArcIt& operator++() {
141 141
        current =
142 142
          path->digraph.source(path->predMatrixMap(path->source, current));
143 143
        if (path->predMatrixMap(path->source, current) == INVALID)
144 144
          current = INVALID;
145 145
        return *this;
146 146
      }
147 147

	
148 148
      bool operator==(const RevArcIt& e) const {
149 149
        return current == e.current;
150 150
      }
151 151

	
152 152
      bool operator!=(const RevArcIt& e) const {
153 153
        return current != e.current;
154 154
      }
155 155

	
156 156
      bool operator<(const RevArcIt& e) const {
157 157
        return current < e.current;
158 158
      }
159 159

	
160 160
    private:
161 161
      const PredMatrixMapPath* path;
162 162
      typename Digraph::Node current;
163 163
    };
164 164

	
165 165
  private:
166 166
    const Digraph& digraph;
167 167
    const PredMatrixMap& predMatrixMap;
168 168
    typename Digraph::Node source;
169 169
    typename Digraph::Node target;
170 170
  };
171 171

	
0 comments (0 inline)