237 /// \ref ListDigraph and \ref SmartDigraph, especially using \c OutArcIt |
237 /// \ref ListDigraph and \ref SmartDigraph, especially using \c OutArcIt |
238 /// iterators, since its arcs are stored in an appropriate order. |
238 /// iterators, since its arcs are stored in an appropriate order. |
239 /// However it only provides build() and clear() functions and does not |
239 /// However it only provides build() and clear() functions and does not |
240 /// support any other modification of the digraph. |
240 /// support any other modification of the digraph. |
241 /// |
241 /// |
|
242 /// Since this digraph structure is completely static, its nodes and arcs |
|
243 /// can be indexed with integers from the ranges <tt>[0..nodeNum()-1]</tt> |
|
244 /// and <tt>[0..arcNum()-1]</tt>, respectively. |
|
245 /// The index of an item is the same as its ID, it can be obtained |
|
246 /// using the corresponding \ref index() or \ref concepts::Digraph::id() |
|
247 /// "id()" function. A node or arc with a certain index can be obtained |
|
248 /// using node() or arc(). |
|
249 /// |
242 /// This type fully conforms to the \ref concepts::Digraph "Digraph concept". |
250 /// This type fully conforms to the \ref concepts::Digraph "Digraph concept". |
243 /// Most of its member functions and nested classes are documented |
251 /// Most of its member functions and nested classes are documented |
244 /// only in the concept class. |
252 /// only in the concept class. |
245 /// |
253 /// |
246 /// \sa concepts::Digraph |
254 /// \sa concepts::Digraph |
249 |
257 |
250 typedef ExtendedStaticDigraphBase Parent; |
258 typedef ExtendedStaticDigraphBase Parent; |
251 |
259 |
252 public: |
260 public: |
253 |
261 |
254 /// \brief Clear the digraph. |
262 /// \brief Constructor |
255 /// |
263 /// |
256 /// This function erases all nodes and arcs from the digraph. |
264 /// Default constructor. |
257 void clear() { |
265 StaticDigraph() : Parent() {} |
258 Parent::clear(); |
266 |
259 } |
267 /// \brief The node with the given index. |
260 |
268 /// |
|
269 /// This function returns the node with the given index. |
|
270 /// \sa index() |
|
271 Node node(int ix) const { return Parent::nodeFromId(ix); } |
|
272 |
|
273 /// \brief The arc with the given index. |
|
274 /// |
|
275 /// This function returns the arc with the given index. |
|
276 /// \sa index() |
|
277 Arc arc(int ix) const { return Parent::arcFromId(ix); } |
|
278 |
|
279 /// \brief The index of the given node. |
|
280 /// |
|
281 /// This function returns the index of the the given node. |
|
282 /// \sa node() |
|
283 int index(Node node) const { return Parent::id(node); } |
|
284 |
|
285 /// \brief The index of the given arc. |
|
286 /// |
|
287 /// This function returns the index of the the given arc. |
|
288 /// \sa arc() |
|
289 int index(Arc arc) const { return Parent::id(arc); } |
|
290 |
|
291 /// \brief Number of nodes. |
|
292 /// |
|
293 /// This function returns the number of nodes. |
|
294 int nodeNum() const { return node_num; } |
|
295 |
|
296 /// \brief Number of arcs. |
|
297 /// |
|
298 /// This function returns the number of arcs. |
|
299 int arcNum() const { return arc_num; } |
|
300 |
261 /// \brief Build the digraph copying another digraph. |
301 /// \brief Build the digraph copying another digraph. |
262 /// |
302 /// |
263 /// This function builds the digraph copying another digraph of any |
303 /// 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 |
304 /// kind. It can be called more than once, but in such case, the whole |
265 /// structure and all maps will be cleared and rebuilt. |
305 /// structure and all maps will be cleared and rebuilt. |
286 void build(const Digraph& digraph, NodeRefMap& nodeRef, ArcRefMap& arcRef) { |
326 void build(const Digraph& digraph, NodeRefMap& nodeRef, ArcRefMap& arcRef) { |
287 if (built) Parent::clear(); |
327 if (built) Parent::clear(); |
288 Parent::build(digraph, nodeRef, arcRef); |
328 Parent::build(digraph, nodeRef, arcRef); |
289 } |
329 } |
290 |
330 |
|
331 /// \brief Clear the digraph. |
|
332 /// |
|
333 /// This function erases all nodes and arcs from the digraph. |
|
334 void clear() { |
|
335 Parent::clear(); |
|
336 } |
291 |
337 |
292 protected: |
338 protected: |
293 |
339 |
294 using Parent::fastFirstOut; |
340 using Parent::fastFirstOut; |
295 using Parent::fastNextOut; |
341 using Parent::fastNextOut; |