... | ... |
@@ -1141,83 +1141,83 @@ |
1141 | 1141 |
inline typename Graph::Edge |
1142 | 1142 |
findEdge(const Graph &g, typename Graph::Node u, typename Graph::Node v, |
1143 | 1143 |
typename Graph::Edge p = INVALID) { |
1144 | 1144 |
return _core_bits::FindEdgeSelector<Graph>::find(g, u, v, p); |
1145 | 1145 |
} |
1146 | 1146 |
|
1147 | 1147 |
/// \brief Iterator for iterating on parallel edges connecting the same nodes. |
1148 | 1148 |
/// |
1149 | 1149 |
/// Iterator for iterating on parallel edges connecting the same nodes. |
1150 | 1150 |
/// It is a higher level interface for the findEdge() function. You can |
1151 | 1151 |
/// use it the following way: |
1152 | 1152 |
///\code |
1153 | 1153 |
/// for (ConEdgeIt<Graph> it(g, u, v); it != INVALID; ++it) { |
1154 | 1154 |
/// ... |
1155 | 1155 |
/// } |
1156 | 1156 |
///\endcode |
1157 | 1157 |
/// |
1158 | 1158 |
///\sa findEdge() |
1159 | 1159 |
template <typename _Graph> |
1160 | 1160 |
class ConEdgeIt : public _Graph::Edge { |
1161 | 1161 |
public: |
1162 | 1162 |
|
1163 | 1163 |
typedef _Graph Graph; |
1164 | 1164 |
typedef typename Graph::Edge Parent; |
1165 | 1165 |
|
1166 | 1166 |
typedef typename Graph::Edge Edge; |
1167 | 1167 |
typedef typename Graph::Node Node; |
1168 | 1168 |
|
1169 | 1169 |
/// \brief Constructor. |
1170 | 1170 |
/// |
1171 | 1171 |
/// Construct a new ConEdgeIt iterating on the edges that |
1172 | 1172 |
/// connects nodes \c u and \c v. |
1173 |
ConEdgeIt(const Graph& g, Node u, Node v) : _graph(g) { |
|
1174 |
Parent::operator=(findEdge(_graph, u, v)); |
|
1173 |
ConEdgeIt(const Graph& g, Node u, Node v) : _graph(g), _u(u), _v(v) { |
|
1174 |
Parent::operator=(findEdge(_graph, _u, _v)); |
|
1175 | 1175 |
} |
1176 | 1176 |
|
1177 | 1177 |
/// \brief Constructor. |
1178 | 1178 |
/// |
1179 | 1179 |
/// Construct a new ConEdgeIt that continues iterating from edge \c e. |
1180 | 1180 |
ConEdgeIt(const Graph& g, Edge e) : Parent(e), _graph(g) {} |
1181 | 1181 |
|
1182 | 1182 |
/// \brief Increment operator. |
1183 | 1183 |
/// |
1184 | 1184 |
/// It increments the iterator and gives back the next edge. |
1185 | 1185 |
ConEdgeIt& operator++() { |
1186 |
Parent::operator=(findEdge(_graph, _graph.u(*this), |
|
1187 |
_graph.v(*this), *this)); |
|
1186 |
Parent::operator=(findEdge(_graph, _u, _v, *this)); |
|
1188 | 1187 |
return *this; |
1189 | 1188 |
} |
1190 | 1189 |
private: |
1191 | 1190 |
const Graph& _graph; |
1191 |
Node _u, _v; |
|
1192 | 1192 |
}; |
1193 | 1193 |
|
1194 | 1194 |
|
1195 | 1195 |
///Dynamic arc look-up between given endpoints. |
1196 | 1196 |
|
1197 | 1197 |
///Using this class, you can find an arc in a digraph from a given |
1198 | 1198 |
///source to a given target in amortized time <em>O</em>(log<em>d</em>), |
1199 | 1199 |
///where <em>d</em> is the out-degree of the source node. |
1200 | 1200 |
/// |
1201 | 1201 |
///It is possible to find \e all parallel arcs between two nodes with |
1202 | 1202 |
///the \c operator() member. |
1203 | 1203 |
/// |
1204 | 1204 |
///This is a dynamic data structure. Consider to use \ref ArcLookUp or |
1205 | 1205 |
///\ref AllArcLookUp if your digraph is not changed so frequently. |
1206 | 1206 |
/// |
1207 | 1207 |
///This class uses a self-adjusting binary search tree, the Splay tree |
1208 | 1208 |
///of Sleator and Tarjan to guarantee the logarithmic amortized |
1209 | 1209 |
///time bound for arc look-ups. This class also guarantees the |
1210 | 1210 |
///optimal time bound in a constant factor for any distribution of |
1211 | 1211 |
///queries. |
1212 | 1212 |
/// |
1213 | 1213 |
///\tparam G The type of the underlying digraph. |
1214 | 1214 |
/// |
1215 | 1215 |
///\sa ArcLookUp |
1216 | 1216 |
///\sa AllArcLookUp |
1217 | 1217 |
template<class G> |
1218 | 1218 |
class DynArcLookUp |
1219 | 1219 |
: protected ItemSetTraits<G, typename G::Arc>::ItemNotifier::ObserverBase |
1220 | 1220 |
{ |
1221 | 1221 |
public: |
1222 | 1222 |
typedef typename ItemSetTraits<G, typename G::Arc> |
1223 | 1223 |
::ItemNotifier::ObserverBase Parent; |
0 comments (0 inline)