224 }; |
224 }; |
225 |
225 |
226 typedef DigraphExtender<StaticDigraphBase> ExtendedStaticDigraphBase; |
226 typedef DigraphExtender<StaticDigraphBase> ExtendedStaticDigraphBase; |
227 |
227 |
228 |
228 |
|
229 /// \ingroup graphs |
|
230 /// |
|
231 /// \brief A static directed graph class. |
|
232 /// |
|
233 /// \ref StaticDigraph is a highly efficient digraph implementation, |
|
234 /// but it is fully static. |
|
235 /// It stores only two \c int values for each node and only four \c int |
|
236 /// values for each arc. Moreover it provides faster item iteration than |
|
237 /// \ref ListDigraph and \ref SmartDigraph, especially using \c OutArcIt |
|
238 /// iterators, since its arcs are stored in an appropriate order. |
|
239 /// However it only provides build() and clear() functions and does not |
|
240 /// support any other modification of the digraph. |
|
241 /// |
|
242 /// This type fully conforms to the \ref concepts::Digraph "Digraph concept". |
|
243 /// Most of its member functions and nested classes are documented |
|
244 /// only in the concept class. |
|
245 /// |
|
246 /// \sa concepts::Digraph |
229 class StaticDigraph : public ExtendedStaticDigraphBase { |
247 class StaticDigraph : public ExtendedStaticDigraphBase { |
230 public: |
248 public: |
231 |
249 |
232 typedef ExtendedStaticDigraphBase Parent; |
250 typedef ExtendedStaticDigraphBase Parent; |
233 |
251 |
234 public: |
252 public: |
235 |
253 |
|
254 /// \brief Clear the digraph. |
|
255 /// |
|
256 /// This function erases all nodes and arcs from the digraph. |
|
257 void clear() { |
|
258 Parent::clear(); |
|
259 } |
|
260 |
|
261 /// \brief Build the digraph copying another digraph. |
|
262 /// |
|
263 /// This function builds the digraph copying another digraph of any |
|
264 /// kind. It can be called more than once, but in such case, the whole |
|
265 /// structure and all maps will be cleared and rebuilt. |
|
266 /// |
|
267 /// This method also makes possible to copy a digraph to a StaticDigraph |
|
268 /// structure using \ref DigraphCopy. |
|
269 /// |
|
270 /// \param digraph An existing digraph to be copied. |
|
271 /// \param nodeRef The node references will be copied into this map. |
|
272 /// Its key type must be \c Digraph::Node and its value type must be |
|
273 /// \c StaticDigraph::Node. |
|
274 /// It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" |
|
275 /// concept. |
|
276 /// \param arcRef The arc references will be copied into this map. |
|
277 /// Its key type must be \c Digraph::Arc and its value type must be |
|
278 /// \c StaticDigraph::Arc. |
|
279 /// It must conform to the \ref concepts::WriteMap "WriteMap" concept. |
|
280 /// |
|
281 /// \note If you do not need the arc references, then you could use |
|
282 /// \ref NullMap for the last parameter. However the node references |
|
283 /// are required by the function itself, thus they must be readable |
|
284 /// from the map. |
236 template <typename Digraph, typename NodeRefMap, typename ArcRefMap> |
285 template <typename Digraph, typename NodeRefMap, typename ArcRefMap> |
237 void build(const Digraph& digraph, NodeRefMap& nodeRef, ArcRefMap& arcRef) { |
286 void build(const Digraph& digraph, NodeRefMap& nodeRef, ArcRefMap& arcRef) { |
238 if (built) Parent::clear(); |
287 if (built) Parent::clear(); |
239 Parent::build(digraph, nodeRef, arcRef); |
288 Parent::build(digraph, nodeRef, arcRef); |
240 } |
289 } |