376 | | /// This function builds the digraph from the given arc list. |
377 | | /// It can be called more than once, but in such case, the whole |
378 | | /// structure and all maps will be cleared and rebuilt. |
| 381 | /// This function builds the digraph from the given arc list. It |
| 382 | /// can be called more than once, but in such case, the whole |
| 383 | /// structure and all maps will be cleared and rebuilt. The |
| 384 | /// number of arcs is determined by calling |
| 385 | /// <tt>std::distance(begin, end)</tt>. |
| 419 | /// \brief Build the digraph from an arc list. |
| 420 | /// |
| 421 | /// This version requires the number of arcs to be specified |
| 422 | /// explicitly, but avoids a possibly expensive call to |
| 423 | /// <tt>std::distance()</tt>. |
| 424 | /// |
| 425 | /// This function builds the digraph from the given arc list. It |
| 426 | /// can be called more than once, but in such case, the whole |
| 427 | /// structure and all maps will be cleared and rebuilt. |
| 428 | /// |
| 429 | /// The list of the arcs must be given in the range <tt>[begin, end)</tt> |
| 430 | /// specified by STL compatible itartors whose \c value_type must be |
| 431 | /// <tt>std::pair<int,int></tt>. |
| 432 | /// Each arc must be specified by a pair of integer indices |
| 433 | /// from the range <tt>[0..n-1]</tt>. <i>The pairs must be in a |
| 434 | /// non-decreasing order with respect to their first values.</i> |
| 435 | /// If the k-th pair in the list is <tt>(i,j)</tt>, then |
| 436 | /// <tt>arc(k-1)</tt> will connect <tt>node(i)</tt> to <tt>node(j)</tt>. |
| 437 | /// |
| 438 | /// \param n The number of nodes. |
| 439 | /// \param begin An iterator pointing to the beginning of the arc list. |
| 440 | /// \param end An iterator pointing to the end of the arc list. |
| 441 | /// |
| 442 | /// For example, a simple digraph can be constructed like this. |
| 443 | /// \code |
| 444 | /// std::vector<std::pair<int,int> > arcs; |
| 445 | /// arcs.push_back(std::make_pair(0,1)); |
| 446 | /// arcs.push_back(std::make_pair(0,2)); |
| 447 | /// arcs.push_back(std::make_pair(1,3)); |
| 448 | /// arcs.push_back(std::make_pair(1,2)); |
| 449 | /// arcs.push_back(std::make_pair(3,0)); |
| 450 | /// StaticDigraph gr; |
| 451 | /// gr.build(4, arcs.begin(), arcs.end()); |
| 452 | /// \endcode |
| 453 | template <typename ArcListIterator> |
| 454 | void build(int n_nodes, int n_arcs, ArcListIterator begin, ArcListIterator end) { |
| 455 | if (built) Parent::clear(); |
| 456 | StaticDigraphBase::build(n_nodes, n_arcs, begin, end); |
| 457 | notifier(Node()).build(); |
| 458 | notifier(Arc()).build(); |
| 459 | } |
| 460 | |