0
11
0
| ... | ... |
@@ -351,24 +351,27 @@ |
| 351 | 351 |
/// \ingroup graph_adaptors |
| 352 | 352 |
/// |
| 353 | 353 |
/// \brief Adaptor class for reversing the orientation of the arcs in |
| 354 | 354 |
/// a digraph. |
| 355 | 355 |
/// |
| 356 | 356 |
/// ReverseDigraph can be used for reversing the arcs in a digraph. |
| 357 | 357 |
/// It conforms to the \ref concepts::Digraph "Digraph" concept. |
| 358 | 358 |
/// |
| 359 | 359 |
/// The adapted digraph can also be modified through this adaptor |
| 360 | 360 |
/// by adding or removing nodes or arcs, unless the \c GR template |
| 361 | 361 |
/// parameter is set to be \c const. |
| 362 | 362 |
/// |
| 363 |
/// This class provides item counting in the same time as the adapted |
|
| 364 |
/// digraph structure. |
|
| 365 |
/// |
|
| 363 | 366 |
/// \tparam DGR The type of the adapted digraph. |
| 364 | 367 |
/// It must conform to the \ref concepts::Digraph "Digraph" concept. |
| 365 | 368 |
/// It can also be specified to be \c const. |
| 366 | 369 |
/// |
| 367 | 370 |
/// \note The \c Node and \c Arc types of this adaptor and the adapted |
| 368 | 371 |
/// digraph are convertible to each other. |
| 369 | 372 |
template<typename DGR> |
| 370 | 373 |
#ifdef DOXYGEN |
| 371 | 374 |
class ReverseDigraph {
|
| 372 | 375 |
#else |
| 373 | 376 |
class ReverseDigraph : |
| 374 | 377 |
public DigraphAdaptorExtender<ReverseDigraphBase<DGR> > {
|
| ... | ... |
@@ -710,24 +713,26 @@ |
| 710 | 713 |
/// SubDigraph can be used for hiding nodes and arcs in a digraph. |
| 711 | 714 |
/// A \c bool node map and a \c bool arc map must be specified, which |
| 712 | 715 |
/// define the filters for nodes and arcs. |
| 713 | 716 |
/// Only the nodes and arcs with \c true filter value are |
| 714 | 717 |
/// shown in the subdigraph. The arcs that are incident to hidden |
| 715 | 718 |
/// nodes are also filtered out. |
| 716 | 719 |
/// This adaptor conforms to the \ref concepts::Digraph "Digraph" concept. |
| 717 | 720 |
/// |
| 718 | 721 |
/// The adapted digraph can also be modified through this adaptor |
| 719 | 722 |
/// by adding or removing nodes or arcs, unless the \c GR template |
| 720 | 723 |
/// parameter is set to be \c const. |
| 721 | 724 |
/// |
| 725 |
/// This class provides only linear time counting for nodes and arcs. |
|
| 726 |
/// |
|
| 722 | 727 |
/// \tparam DGR The type of the adapted digraph. |
| 723 | 728 |
/// It must conform to the \ref concepts::Digraph "Digraph" concept. |
| 724 | 729 |
/// It can also be specified to be \c const. |
| 725 | 730 |
/// \tparam NF The type of the node filter map. |
| 726 | 731 |
/// It must be a \c bool (or convertible) node map of the |
| 727 | 732 |
/// adapted digraph. The default type is |
| 728 | 733 |
/// \ref concepts::Digraph::NodeMap "DGR::NodeMap<bool>". |
| 729 | 734 |
/// \tparam AF The type of the arc filter map. |
| 730 | 735 |
/// It must be \c bool (or convertible) arc map of the |
| 731 | 736 |
/// adapted digraph. The default type is |
| 732 | 737 |
/// \ref concepts::Digraph::ArcMap "DGR::ArcMap<bool>". |
| 733 | 738 |
/// |
| ... | ... |
@@ -1305,24 +1310,26 @@ |
| 1305 | 1310 |
/// SubGraph can be used for hiding nodes and edges in a graph. |
| 1306 | 1311 |
/// A \c bool node map and a \c bool edge map must be specified, which |
| 1307 | 1312 |
/// define the filters for nodes and edges. |
| 1308 | 1313 |
/// Only the nodes and edges with \c true filter value are |
| 1309 | 1314 |
/// shown in the subgraph. The edges that are incident to hidden |
| 1310 | 1315 |
/// nodes are also filtered out. |
| 1311 | 1316 |
/// This adaptor conforms to the \ref concepts::Graph "Graph" concept. |
| 1312 | 1317 |
/// |
| 1313 | 1318 |
/// The adapted graph can also be modified through this adaptor |
| 1314 | 1319 |
/// by adding or removing nodes or edges, unless the \c GR template |
| 1315 | 1320 |
/// parameter is set to be \c const. |
| 1316 | 1321 |
/// |
| 1322 |
/// This class provides only linear time counting for nodes, edges and arcs. |
|
| 1323 |
/// |
|
| 1317 | 1324 |
/// \tparam GR The type of the adapted graph. |
| 1318 | 1325 |
/// It must conform to the \ref concepts::Graph "Graph" concept. |
| 1319 | 1326 |
/// It can also be specified to be \c const. |
| 1320 | 1327 |
/// \tparam NF The type of the node filter map. |
| 1321 | 1328 |
/// It must be a \c bool (or convertible) node map of the |
| 1322 | 1329 |
/// adapted graph. The default type is |
| 1323 | 1330 |
/// \ref concepts::Graph::NodeMap "GR::NodeMap<bool>". |
| 1324 | 1331 |
/// \tparam EF The type of the edge filter map. |
| 1325 | 1332 |
/// It must be a \c bool (or convertible) edge map of the |
| 1326 | 1333 |
/// adapted graph. The default type is |
| 1327 | 1334 |
/// \ref concepts::Graph::EdgeMap "GR::EdgeMap<bool>". |
| 1328 | 1335 |
/// |
| ... | ... |
@@ -1462,24 +1469,26 @@ |
| 1462 | 1469 |
/// FilterNodes adaptor can be used for hiding nodes in a digraph or a |
| 1463 | 1470 |
/// graph. A \c bool node map must be specified, which defines the filter |
| 1464 | 1471 |
/// for the nodes. Only the nodes with \c true filter value and the |
| 1465 | 1472 |
/// arcs/edges incident to nodes both with \c true filter value are shown |
| 1466 | 1473 |
/// in the subgraph. This adaptor conforms to the \ref concepts::Digraph |
| 1467 | 1474 |
/// "Digraph" concept or the \ref concepts::Graph "Graph" concept |
| 1468 | 1475 |
/// depending on the \c GR template parameter. |
| 1469 | 1476 |
/// |
| 1470 | 1477 |
/// The adapted (di)graph can also be modified through this adaptor |
| 1471 | 1478 |
/// by adding or removing nodes or arcs/edges, unless the \c GR template |
| 1472 | 1479 |
/// parameter is set to be \c const. |
| 1473 | 1480 |
/// |
| 1481 |
/// This class provides only linear time item counting. |
|
| 1482 |
/// |
|
| 1474 | 1483 |
/// \tparam GR The type of the adapted digraph or graph. |
| 1475 | 1484 |
/// It must conform to the \ref concepts::Digraph "Digraph" concept |
| 1476 | 1485 |
/// or the \ref concepts::Graph "Graph" concept. |
| 1477 | 1486 |
/// It can also be specified to be \c const. |
| 1478 | 1487 |
/// \tparam NF The type of the node filter map. |
| 1479 | 1488 |
/// It must be a \c bool (or convertible) node map of the |
| 1480 | 1489 |
/// adapted (di)graph. The default type is |
| 1481 | 1490 |
/// \ref concepts::Graph::NodeMap "GR::NodeMap<bool>". |
| 1482 | 1491 |
/// |
| 1483 | 1492 |
/// \note The \c Node and <tt>Arc/Edge</tt> types of this adaptor and the |
| 1484 | 1493 |
/// adapted (di)graph are convertible to each other. |
| 1485 | 1494 |
#ifdef DOXYGEN |
| ... | ... |
@@ -1610,24 +1619,26 @@ |
| 1610 | 1619 |
/// \brief Adaptor class for hiding arcs in a digraph. |
| 1611 | 1620 |
/// |
| 1612 | 1621 |
/// FilterArcs adaptor can be used for hiding arcs in a digraph. |
| 1613 | 1622 |
/// A \c bool arc map must be specified, which defines the filter for |
| 1614 | 1623 |
/// the arcs. Only the arcs with \c true filter value are shown in the |
| 1615 | 1624 |
/// subdigraph. This adaptor conforms to the \ref concepts::Digraph |
| 1616 | 1625 |
/// "Digraph" concept. |
| 1617 | 1626 |
/// |
| 1618 | 1627 |
/// The adapted digraph can also be modified through this adaptor |
| 1619 | 1628 |
/// by adding or removing nodes or arcs, unless the \c GR template |
| 1620 | 1629 |
/// parameter is set to be \c const. |
| 1621 | 1630 |
/// |
| 1631 |
/// This class provides only linear time counting for nodes and arcs. |
|
| 1632 |
/// |
|
| 1622 | 1633 |
/// \tparam DGR The type of the adapted digraph. |
| 1623 | 1634 |
/// It must conform to the \ref concepts::Digraph "Digraph" concept. |
| 1624 | 1635 |
/// It can also be specified to be \c const. |
| 1625 | 1636 |
/// \tparam AF The type of the arc filter map. |
| 1626 | 1637 |
/// It must be a \c bool (or convertible) arc map of the |
| 1627 | 1638 |
/// adapted digraph. The default type is |
| 1628 | 1639 |
/// \ref concepts::Digraph::ArcMap "DGR::ArcMap<bool>". |
| 1629 | 1640 |
/// |
| 1630 | 1641 |
/// \note The \c Node and \c Arc types of this adaptor and the adapted |
| 1631 | 1642 |
/// digraph are convertible to each other. |
| 1632 | 1643 |
#ifdef DOXYGEN |
| 1633 | 1644 |
template<typename DGR, |
| ... | ... |
@@ -1720,24 +1731,26 @@ |
| 1720 | 1731 |
/// \brief Adaptor class for hiding edges in a graph. |
| 1721 | 1732 |
/// |
| 1722 | 1733 |
/// FilterEdges adaptor can be used for hiding edges in a graph. |
| 1723 | 1734 |
/// A \c bool edge map must be specified, which defines the filter for |
| 1724 | 1735 |
/// the edges. Only the edges with \c true filter value are shown in the |
| 1725 | 1736 |
/// subgraph. This adaptor conforms to the \ref concepts::Graph |
| 1726 | 1737 |
/// "Graph" concept. |
| 1727 | 1738 |
/// |
| 1728 | 1739 |
/// The adapted graph can also be modified through this adaptor |
| 1729 | 1740 |
/// by adding or removing nodes or edges, unless the \c GR template |
| 1730 | 1741 |
/// parameter is set to be \c const. |
| 1731 | 1742 |
/// |
| 1743 |
/// This class provides only linear time counting for nodes, edges and arcs. |
|
| 1744 |
/// |
|
| 1732 | 1745 |
/// \tparam GR The type of the adapted graph. |
| 1733 | 1746 |
/// It must conform to the \ref concepts::Graph "Graph" concept. |
| 1734 | 1747 |
/// It can also be specified to be \c const. |
| 1735 | 1748 |
/// \tparam EF The type of the edge filter map. |
| 1736 | 1749 |
/// It must be a \c bool (or convertible) edge map of the |
| 1737 | 1750 |
/// adapted graph. The default type is |
| 1738 | 1751 |
/// \ref concepts::Graph::EdgeMap "GR::EdgeMap<bool>". |
| 1739 | 1752 |
/// |
| 1740 | 1753 |
/// \note The \c Node, \c Edge and \c Arc types of this adaptor and the |
| 1741 | 1754 |
/// adapted graph are convertible to each other. |
| 1742 | 1755 |
#ifdef DOXYGEN |
| 1743 | 1756 |
template<typename GR, |
| ... | ... |
@@ -2223,24 +2236,27 @@ |
| 2223 | 2236 |
/// |
| 2224 | 2237 |
/// \brief Adaptor class for viewing a digraph as an undirected graph. |
| 2225 | 2238 |
/// |
| 2226 | 2239 |
/// Undirector adaptor can be used for viewing a digraph as an undirected |
| 2227 | 2240 |
/// graph. All arcs of the underlying digraph are showed in the |
| 2228 | 2241 |
/// adaptor as an edge (and also as a pair of arcs, of course). |
| 2229 | 2242 |
/// This adaptor conforms to the \ref concepts::Graph "Graph" concept. |
| 2230 | 2243 |
/// |
| 2231 | 2244 |
/// The adapted digraph can also be modified through this adaptor |
| 2232 | 2245 |
/// by adding or removing nodes or edges, unless the \c GR template |
| 2233 | 2246 |
/// parameter is set to be \c const. |
| 2234 | 2247 |
/// |
| 2248 |
/// This class provides item counting in the same time as the adapted |
|
| 2249 |
/// digraph structure. |
|
| 2250 |
/// |
|
| 2235 | 2251 |
/// \tparam DGR The type of the adapted digraph. |
| 2236 | 2252 |
/// It must conform to the \ref concepts::Digraph "Digraph" concept. |
| 2237 | 2253 |
/// It can also be specified to be \c const. |
| 2238 | 2254 |
/// |
| 2239 | 2255 |
/// \note The \c Node type of this adaptor and the adapted digraph are |
| 2240 | 2256 |
/// convertible to each other, moreover the \c Edge type of the adaptor |
| 2241 | 2257 |
/// and the \c Arc type of the adapted digraph are also convertible to |
| 2242 | 2258 |
/// each other. |
| 2243 | 2259 |
/// (Thus the \c Arc type of the adaptor is convertible to the \c Arc type |
| 2244 | 2260 |
/// of the adapted digraph.) |
| 2245 | 2261 |
template<typename DGR> |
| 2246 | 2262 |
#ifdef DOXYGEN |
| ... | ... |
@@ -2526,24 +2542,27 @@ |
| 2526 | 2542 |
/// |
| 2527 | 2543 |
/// Orienter adaptor can be used for orienting the edges of a graph to |
| 2528 | 2544 |
/// get a digraph. A \c bool edge map of the underlying graph must be |
| 2529 | 2545 |
/// specified, which define the direction of the arcs in the adaptor. |
| 2530 | 2546 |
/// The arcs can be easily reversed by the \c reverseArc() member function |
| 2531 | 2547 |
/// of the adaptor. |
| 2532 | 2548 |
/// This class conforms to the \ref concepts::Digraph "Digraph" concept. |
| 2533 | 2549 |
/// |
| 2534 | 2550 |
/// The adapted graph can also be modified through this adaptor |
| 2535 | 2551 |
/// by adding or removing nodes or arcs, unless the \c GR template |
| 2536 | 2552 |
/// parameter is set to be \c const. |
| 2537 | 2553 |
/// |
| 2554 |
/// This class provides item counting in the same time as the adapted |
|
| 2555 |
/// graph structure. |
|
| 2556 |
/// |
|
| 2538 | 2557 |
/// \tparam GR The type of the adapted graph. |
| 2539 | 2558 |
/// It must conform to the \ref concepts::Graph "Graph" concept. |
| 2540 | 2559 |
/// It can also be specified to be \c const. |
| 2541 | 2560 |
/// \tparam DM The type of the direction map. |
| 2542 | 2561 |
/// It must be a \c bool (or convertible) edge map of the |
| 2543 | 2562 |
/// adapted graph. The default type is |
| 2544 | 2563 |
/// \ref concepts::Graph::EdgeMap "GR::EdgeMap<bool>". |
| 2545 | 2564 |
/// |
| 2546 | 2565 |
/// \note The \c Node type of this adaptor and the adapted graph are |
| 2547 | 2566 |
/// convertible to each other, moreover the \c Arc type of the adaptor |
| 2548 | 2567 |
/// and the \c Edge type of the adapted graph are also convertible to |
| 2549 | 2568 |
/// each other. |
| ... | ... |
@@ -2669,24 +2688,26 @@ |
| 2669 | 2688 |
/// Let \f$ flow, cap: A\to F \f$ be functions on the arcs. |
| 2670 | 2689 |
/// This adaptor implements a digraph structure with node set \f$ V \f$ |
| 2671 | 2690 |
/// and arc set \f$ A_{forward}\cup A_{backward} \f$,
|
| 2672 | 2691 |
/// where \f$ A_{forward}=\{uv : uv\in A, flow(uv)<cap(uv)\} \f$ and
|
| 2673 | 2692 |
/// \f$ A_{backward}=\{vu : uv\in A, flow(uv)>0\} \f$, i.e. the so
|
| 2674 | 2693 |
/// called residual digraph. |
| 2675 | 2694 |
/// When the union \f$ A_{forward}\cup A_{backward} \f$ is taken,
|
| 2676 | 2695 |
/// multiplicities are counted, i.e. the adaptor has exactly |
| 2677 | 2696 |
/// \f$ |A_{forward}| + |A_{backward}|\f$ arcs (it may have parallel
|
| 2678 | 2697 |
/// arcs). |
| 2679 | 2698 |
/// This class conforms to the \ref concepts::Digraph "Digraph" concept. |
| 2680 | 2699 |
/// |
| 2700 |
/// This class provides only linear time counting for nodes and arcs. |
|
| 2701 |
/// |
|
| 2681 | 2702 |
/// \tparam DGR The type of the adapted digraph. |
| 2682 | 2703 |
/// It must conform to the \ref concepts::Digraph "Digraph" concept. |
| 2683 | 2704 |
/// It is implicitly \c const. |
| 2684 | 2705 |
/// \tparam CM The type of the capacity map. |
| 2685 | 2706 |
/// It must be an arc map of some numerical type, which defines |
| 2686 | 2707 |
/// the capacities in the flow problem. It is implicitly \c const. |
| 2687 | 2708 |
/// The default type is |
| 2688 | 2709 |
/// \ref concepts::Digraph::ArcMap "GR::ArcMap<int>". |
| 2689 | 2710 |
/// \tparam FM The type of the flow map. |
| 2690 | 2711 |
/// It must be an arc map of some numerical type, which defines |
| 2691 | 2712 |
/// the flow values in the flow problem. The default type is \c CM. |
| 2692 | 2713 |
/// \tparam TL The tolerance type for handling inexact computation. |
| ... | ... |
@@ -3316,24 +3337,27 @@ |
| 3316 | 3337 |
/// new target of the arc will be \f$ u_{in} \f$ and similarly the
|
| 3317 | 3338 |
/// source of each original \f$ (u, v) \f$ arc will be \f$ u_{out} \f$.
|
| 3318 | 3339 |
/// The adaptor adds an additional \e bind \e arc from \f$ u_{in} \f$
|
| 3319 | 3340 |
/// to \f$ u_{out} \f$ for each node \f$ u \f$ of the original digraph.
|
| 3320 | 3341 |
/// |
| 3321 | 3342 |
/// The aim of this class is running an algorithm with respect to node |
| 3322 | 3343 |
/// costs or capacities if the algorithm considers only arc costs or |
| 3323 | 3344 |
/// capacities directly. |
| 3324 | 3345 |
/// In this case you can use \c SplitNodes adaptor, and set the node |
| 3325 | 3346 |
/// costs/capacities of the original digraph to the \e bind \e arcs |
| 3326 | 3347 |
/// in the adaptor. |
| 3327 | 3348 |
/// |
| 3349 |
/// This class provides item counting in the same time as the adapted |
|
| 3350 |
/// digraph structure. |
|
| 3351 |
/// |
|
| 3328 | 3352 |
/// \tparam DGR The type of the adapted digraph. |
| 3329 | 3353 |
/// It must conform to the \ref concepts::Digraph "Digraph" concept. |
| 3330 | 3354 |
/// It is implicitly \c const. |
| 3331 | 3355 |
/// |
| 3332 | 3356 |
/// \note The \c Node type of this adaptor is converible to the \c Node |
| 3333 | 3357 |
/// type of the adapted digraph. |
| 3334 | 3358 |
template <typename DGR> |
| 3335 | 3359 |
#ifdef DOXYGEN |
| 3336 | 3360 |
class SplitNodes {
|
| 3337 | 3361 |
#else |
| 3338 | 3362 |
class SplitNodes |
| 3339 | 3363 |
: public DigraphAdaptorExtender<SplitNodesBase<const DGR> > {
|
| ... | ... |
@@ -692,30 +692,26 @@ |
| 692 | 692 |
/// b.addSource(s); |
| 693 | 693 |
/// b.start(t); |
| 694 | 694 |
///\endcode |
| 695 | 695 |
bool run(Node s,Node t) {
|
| 696 | 696 |
init(); |
| 697 | 697 |
addSource(s); |
| 698 | 698 |
start(t); |
| 699 | 699 |
return reached(t); |
| 700 | 700 |
} |
| 701 | 701 |
|
| 702 | 702 |
///Runs the algorithm to visit all nodes in the digraph. |
| 703 | 703 |
|
| 704 |
///This method runs the %BFS algorithm in order to |
|
| 705 |
///compute the shortest path to each node. |
|
| 706 |
/// |
|
| 707 |
///The algorithm computes |
|
| 708 |
///- the shortest path tree (forest), |
|
| 709 |
///- the distance of each node from the root(s). |
|
| 704 |
///This method runs the %BFS algorithm in order to visit all nodes |
|
| 705 |
///in the digraph. |
|
| 710 | 706 |
/// |
| 711 | 707 |
///\note <tt>b.run(s)</tt> is just a shortcut of the following code. |
| 712 | 708 |
///\code |
| 713 | 709 |
/// b.init(); |
| 714 | 710 |
/// for (NodeIt n(gr); n != INVALID; ++n) {
|
| 715 | 711 |
/// if (!b.reached(n)) {
|
| 716 | 712 |
/// b.addSource(n); |
| 717 | 713 |
/// b.start(); |
| 718 | 714 |
/// } |
| 719 | 715 |
/// } |
| 720 | 716 |
///\endcode |
| 721 | 717 |
void run() {
|
| ... | ... |
@@ -1037,26 +1033,26 @@ |
| 1037 | 1033 |
if (Base::_processed) |
| 1038 | 1034 |
alg.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed)); |
| 1039 | 1035 |
alg.run(s,t); |
| 1040 | 1036 |
if (Base::_path) |
| 1041 | 1037 |
*reinterpret_cast<Path*>(Base::_path) = alg.path(t); |
| 1042 | 1038 |
if (Base::_di) |
| 1043 | 1039 |
*Base::_di = alg.dist(t); |
| 1044 | 1040 |
return alg.reached(t); |
| 1045 | 1041 |
} |
| 1046 | 1042 |
|
| 1047 | 1043 |
///Runs BFS algorithm to visit all nodes in the digraph. |
| 1048 | 1044 |
|
| 1049 |
///This method runs BFS algorithm in order to compute |
|
| 1050 |
///the shortest path to each node. |
|
| 1045 |
///This method runs BFS algorithm in order to visit all nodes |
|
| 1046 |
///in the digraph. |
|
| 1051 | 1047 |
void run() |
| 1052 | 1048 |
{
|
| 1053 | 1049 |
run(INVALID); |
| 1054 | 1050 |
} |
| 1055 | 1051 |
|
| 1056 | 1052 |
template<class T> |
| 1057 | 1053 |
struct SetPredMapBase : public Base {
|
| 1058 | 1054 |
typedef T PredMap; |
| 1059 | 1055 |
static PredMap *createPredMap(const Digraph &) { return 0; };
|
| 1060 | 1056 |
SetPredMapBase(const TR &b) : TR(b) {}
|
| 1061 | 1057 |
}; |
| 1062 | 1058 |
|
| ... | ... |
@@ -1686,30 +1682,26 @@ |
| 1686 | 1682 |
/// b.addSource(s); |
| 1687 | 1683 |
/// b.start(t); |
| 1688 | 1684 |
///\endcode |
| 1689 | 1685 |
bool run(Node s,Node t) {
|
| 1690 | 1686 |
init(); |
| 1691 | 1687 |
addSource(s); |
| 1692 | 1688 |
start(t); |
| 1693 | 1689 |
return reached(t); |
| 1694 | 1690 |
} |
| 1695 | 1691 |
|
| 1696 | 1692 |
/// \brief Runs the algorithm to visit all nodes in the digraph. |
| 1697 | 1693 |
/// |
| 1698 |
/// This method runs the %BFS algorithm in order to |
|
| 1699 |
/// compute the shortest path to each node. |
|
| 1700 |
/// |
|
| 1701 |
/// The algorithm computes |
|
| 1702 |
/// - the shortest path tree (forest), |
|
| 1703 |
/// - the distance of each node from the root(s). |
|
| 1694 |
/// This method runs the %BFS algorithm in order to visit all nodes |
|
| 1695 |
/// in the digraph. |
|
| 1704 | 1696 |
/// |
| 1705 | 1697 |
/// \note <tt>b.run(s)</tt> is just a shortcut of the following code. |
| 1706 | 1698 |
///\code |
| 1707 | 1699 |
/// b.init(); |
| 1708 | 1700 |
/// for (NodeIt n(gr); n != INVALID; ++n) {
|
| 1709 | 1701 |
/// if (!b.reached(n)) {
|
| 1710 | 1702 |
/// b.addSource(n); |
| 1711 | 1703 |
/// b.start(); |
| 1712 | 1704 |
/// } |
| 1713 | 1705 |
/// } |
| 1714 | 1706 |
///\endcode |
| 1715 | 1707 |
void run() {
|
| ... | ... |
@@ -624,30 +624,26 @@ |
| 624 | 624 |
/// d.addSource(s); |
| 625 | 625 |
/// d.start(t); |
| 626 | 626 |
///\endcode |
| 627 | 627 |
bool run(Node s,Node t) {
|
| 628 | 628 |
init(); |
| 629 | 629 |
addSource(s); |
| 630 | 630 |
start(t); |
| 631 | 631 |
return reached(t); |
| 632 | 632 |
} |
| 633 | 633 |
|
| 634 | 634 |
///Runs the algorithm to visit all nodes in the digraph. |
| 635 | 635 |
|
| 636 |
///This method runs the %DFS algorithm in order to compute the |
|
| 637 |
///%DFS path to each node. |
|
| 638 |
/// |
|
| 639 |
///The algorithm computes |
|
| 640 |
///- the %DFS tree (forest), |
|
| 641 |
///- the distance of each node from the root(s) in the %DFS tree. |
|
| 636 |
///This method runs the %DFS algorithm in order to visit all nodes |
|
| 637 |
///in the digraph. |
|
| 642 | 638 |
/// |
| 643 | 639 |
///\note <tt>d.run()</tt> is just a shortcut of the following code. |
| 644 | 640 |
///\code |
| 645 | 641 |
/// d.init(); |
| 646 | 642 |
/// for (NodeIt n(digraph); n != INVALID; ++n) {
|
| 647 | 643 |
/// if (!d.reached(n)) {
|
| 648 | 644 |
/// d.addSource(n); |
| 649 | 645 |
/// d.start(); |
| 650 | 646 |
/// } |
| 651 | 647 |
/// } |
| 652 | 648 |
///\endcode |
| 653 | 649 |
void run() {
|
| ... | ... |
@@ -967,26 +963,26 @@ |
| 967 | 963 |
if (Base::_processed) |
| 968 | 964 |
alg.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed)); |
| 969 | 965 |
alg.run(s,t); |
| 970 | 966 |
if (Base::_path) |
| 971 | 967 |
*reinterpret_cast<Path*>(Base::_path) = alg.path(t); |
| 972 | 968 |
if (Base::_di) |
| 973 | 969 |
*Base::_di = alg.dist(t); |
| 974 | 970 |
return alg.reached(t); |
| 975 | 971 |
} |
| 976 | 972 |
|
| 977 | 973 |
///Runs DFS algorithm to visit all nodes in the digraph. |
| 978 | 974 |
|
| 979 |
///This method runs DFS algorithm in order to compute |
|
| 980 |
///the DFS path to each node. |
|
| 975 |
///This method runs DFS algorithm in order to visit all nodes |
|
| 976 |
///in the digraph. |
|
| 981 | 977 |
void run() |
| 982 | 978 |
{
|
| 983 | 979 |
run(INVALID); |
| 984 | 980 |
} |
| 985 | 981 |
|
| 986 | 982 |
template<class T> |
| 987 | 983 |
struct SetPredMapBase : public Base {
|
| 988 | 984 |
typedef T PredMap; |
| 989 | 985 |
static PredMap *createPredMap(const Digraph &) { return 0; };
|
| 990 | 986 |
SetPredMapBase(const TR &b) : TR(b) {}
|
| 991 | 987 |
}; |
| 992 | 988 |
|
| ... | ... |
@@ -1569,30 +1565,26 @@ |
| 1569 | 1565 |
/// d.addSource(s); |
| 1570 | 1566 |
/// d.start(t); |
| 1571 | 1567 |
///\endcode |
| 1572 | 1568 |
bool run(Node s,Node t) {
|
| 1573 | 1569 |
init(); |
| 1574 | 1570 |
addSource(s); |
| 1575 | 1571 |
start(t); |
| 1576 | 1572 |
return reached(t); |
| 1577 | 1573 |
} |
| 1578 | 1574 |
|
| 1579 | 1575 |
/// \brief Runs the algorithm to visit all nodes in the digraph. |
| 1580 | 1576 |
|
| 1581 |
/// This method runs the %DFS algorithm in order to |
|
| 1582 |
/// compute the %DFS path to each node. |
|
| 1583 |
/// |
|
| 1584 |
/// The algorithm computes |
|
| 1585 |
/// - the %DFS tree (forest), |
|
| 1586 |
/// - the distance of each node from the root(s) in the %DFS tree. |
|
| 1577 |
/// This method runs the %DFS algorithm in order to visit all nodes |
|
| 1578 |
/// in the digraph. |
|
| 1587 | 1579 |
/// |
| 1588 | 1580 |
/// \note <tt>d.run()</tt> is just a shortcut of the following code. |
| 1589 | 1581 |
///\code |
| 1590 | 1582 |
/// d.init(); |
| 1591 | 1583 |
/// for (NodeIt n(digraph); n != INVALID; ++n) {
|
| 1592 | 1584 |
/// if (!d.reached(n)) {
|
| 1593 | 1585 |
/// d.addSource(n); |
| 1594 | 1586 |
/// d.start(); |
| 1595 | 1587 |
/// } |
| 1596 | 1588 |
/// } |
| 1597 | 1589 |
///\endcode |
| 1598 | 1590 |
void run() {
|
| ... | ... |
@@ -197,25 +197,25 @@ |
| 197 | 197 |
#else |
| 198 | 198 |
template <typename GR=ListDigraph, |
| 199 | 199 |
typename LEN=typename GR::template ArcMap<int>, |
| 200 | 200 |
typename TR=DijkstraDefaultTraits<GR,LEN> > |
| 201 | 201 |
#endif |
| 202 | 202 |
class Dijkstra {
|
| 203 | 203 |
public: |
| 204 | 204 |
|
| 205 | 205 |
///The type of the digraph the algorithm runs on. |
| 206 | 206 |
typedef typename TR::Digraph Digraph; |
| 207 | 207 |
|
| 208 | 208 |
///The type of the arc lengths. |
| 209 |
typedef typename TR:: |
|
| 209 |
typedef typename TR::Value Value; |
|
| 210 | 210 |
///The type of the map that stores the arc lengths. |
| 211 | 211 |
typedef typename TR::LengthMap LengthMap; |
| 212 | 212 |
///\brief The type of the map that stores the predecessor arcs of the |
| 213 | 213 |
///shortest paths. |
| 214 | 214 |
typedef typename TR::PredMap PredMap; |
| 215 | 215 |
///The type of the map that stores the distances of the nodes. |
| 216 | 216 |
typedef typename TR::DistMap DistMap; |
| 217 | 217 |
///The type of the map that indicates which nodes are processed. |
| 218 | 218 |
typedef typename TR::ProcessedMap ProcessedMap; |
| 219 | 219 |
///The type of the paths. |
| 220 | 220 |
typedef PredMapPath<Digraph, PredMap> Path; |
| 221 | 221 |
///The cross reference type used for the current heap. |
| ... | ... |
@@ -246,31 +246,32 @@ |
| 246 | 246 |
/// Node type as the underlying graph, and each valid node of the |
| 247 | 247 |
/// original graph is valid in this arc set, therefore the node |
| 248 | 248 |
/// objects of the original graph can be used directly with this |
| 249 | 249 |
/// class. The node handling functions (id handling, observing, and |
| 250 | 250 |
/// iterators) works equivalently as in the original graph. |
| 251 | 251 |
/// |
| 252 | 252 |
/// This implementation is based on doubly-linked lists, from each |
| 253 | 253 |
/// node the outgoing and the incoming arcs make up lists, therefore |
| 254 | 254 |
/// one arc can be erased in constant time. It also makes possible, |
| 255 | 255 |
/// that node can be removed from the underlying graph, in this case |
| 256 | 256 |
/// all arcs incident to the given node is erased from the arc set. |
| 257 | 257 |
/// |
| 258 |
/// This class fully conforms to the \ref concepts::Digraph |
|
| 259 |
/// "Digraph" concept. |
|
| 260 |
/// It provides only linear time counting for nodes and arcs. |
|
| 261 |
/// |
|
| 258 | 262 |
/// \param GR The type of the graph which shares its node set with |
| 259 | 263 |
/// this class. Its interface must conform to the |
| 260 | 264 |
/// \ref concepts::Digraph "Digraph" or \ref concepts::Graph "Graph" |
| 261 | 265 |
/// concept. |
| 262 |
/// |
|
| 263 |
/// This class fully conforms to the \ref concepts::Digraph |
|
| 264 |
/// "Digraph" concept. |
|
| 265 | 266 |
template <typename GR> |
| 266 | 267 |
class ListArcSet : public ArcSetExtender<ListArcSetBase<GR> > {
|
| 267 | 268 |
typedef ArcSetExtender<ListArcSetBase<GR> > Parent; |
| 268 | 269 |
|
| 269 | 270 |
public: |
| 270 | 271 |
|
| 271 | 272 |
typedef typename Parent::Node Node; |
| 272 | 273 |
typedef typename Parent::Arc Arc; |
| 273 | 274 |
|
| 274 | 275 |
typedef typename Parent::NodesImplBase NodesImplBase; |
| 275 | 276 |
|
| 276 | 277 |
void eraseNode(const Node& node) {
|
| ... | ... |
@@ -676,31 +677,32 @@ |
| 676 | 677 |
/// as the underlying graph, and each valid node of the original |
| 677 | 678 |
/// graph is valid in this arc set, therefore the node objects of |
| 678 | 679 |
/// the original graph can be used directly with this class. The |
| 679 | 680 |
/// node handling functions (id handling, observing, and iterators) |
| 680 | 681 |
/// works equivalently as in the original graph. |
| 681 | 682 |
/// |
| 682 | 683 |
/// This implementation is based on doubly-linked lists, from each |
| 683 | 684 |
/// node the incident edges make up lists, therefore one edge can be |
| 684 | 685 |
/// erased in constant time. It also makes possible, that node can |
| 685 | 686 |
/// be removed from the underlying graph, in this case all edges |
| 686 | 687 |
/// incident to the given node is erased from the arc set. |
| 687 | 688 |
/// |
| 689 |
/// This class fully conforms to the \ref concepts::Graph "Graph" |
|
| 690 |
/// concept. |
|
| 691 |
/// It provides only linear time counting for nodes, edges and arcs. |
|
| 692 |
/// |
|
| 688 | 693 |
/// \param GR The type of the graph which shares its node set |
| 689 | 694 |
/// with this class. Its interface must conform to the |
| 690 | 695 |
/// \ref concepts::Digraph "Digraph" or \ref concepts::Graph "Graph" |
| 691 | 696 |
/// concept. |
| 692 |
/// |
|
| 693 |
/// This class fully conforms to the \ref concepts::Graph "Graph" |
|
| 694 |
/// concept. |
|
| 695 | 697 |
template <typename GR> |
| 696 | 698 |
class ListEdgeSet : public EdgeSetExtender<ListEdgeSetBase<GR> > {
|
| 697 | 699 |
typedef EdgeSetExtender<ListEdgeSetBase<GR> > Parent; |
| 698 | 700 |
|
| 699 | 701 |
public: |
| 700 | 702 |
|
| 701 | 703 |
typedef typename Parent::Node Node; |
| 702 | 704 |
typedef typename Parent::Arc Arc; |
| 703 | 705 |
typedef typename Parent::Edge Edge; |
| 704 | 706 |
|
| 705 | 707 |
typedef typename Parent::NodesImplBase NodesImplBase; |
| 706 | 708 |
|
| ... | ... |
@@ -945,31 +947,32 @@ |
| 945 | 947 |
/// iterators) works equivalently as in the original graph. |
| 946 | 948 |
/// |
| 947 | 949 |
/// \param GR The type of the graph which shares its node set with |
| 948 | 950 |
/// this class. Its interface must conform to the |
| 949 | 951 |
/// \ref concepts::Digraph "Digraph" or \ref concepts::Graph "Graph" |
| 950 | 952 |
/// concept. |
| 951 | 953 |
/// |
| 952 | 954 |
/// This implementation is slightly faster than the \c ListArcSet, |
| 953 | 955 |
/// because it uses continuous storage for arcs and it uses just |
| 954 | 956 |
/// single-linked lists for enumerate outgoing and incoming |
| 955 | 957 |
/// arcs. Therefore the arcs cannot be erased from the arc sets. |
| 956 | 958 |
/// |
| 959 |
/// This class fully conforms to the \ref concepts::Digraph "Digraph" |
|
| 960 |
/// concept. |
|
| 961 |
/// It provides only linear time counting for nodes and arcs. |
|
| 962 |
/// |
|
| 957 | 963 |
/// \warning If a node is erased from the underlying graph and this |
| 958 | 964 |
/// node is the source or target of one arc in the arc set, then |
| 959 | 965 |
/// the arc set is invalidated, and it cannot be used anymore. The |
| 960 | 966 |
/// validity can be checked with the \c valid() member function. |
| 961 |
/// |
|
| 962 |
/// This class fully conforms to the \ref concepts::Digraph |
|
| 963 |
/// "Digraph" concept. |
|
| 964 | 967 |
template <typename GR> |
| 965 | 968 |
class SmartArcSet : public ArcSetExtender<SmartArcSetBase<GR> > {
|
| 966 | 969 |
typedef ArcSetExtender<SmartArcSetBase<GR> > Parent; |
| 967 | 970 |
|
| 968 | 971 |
public: |
| 969 | 972 |
|
| 970 | 973 |
typedef typename Parent::Node Node; |
| 971 | 974 |
typedef typename Parent::Arc Arc; |
| 972 | 975 |
|
| 973 | 976 |
protected: |
| 974 | 977 |
|
| 975 | 978 |
typedef typename Parent::NodesImplBase NodesImplBase; |
| ... | ... |
@@ -1295,31 +1298,32 @@ |
| 1295 | 1298 |
/// works equivalently as in the original graph. |
| 1296 | 1299 |
/// |
| 1297 | 1300 |
/// \param GR The type of the graph which shares its node set |
| 1298 | 1301 |
/// with this class. Its interface must conform to the |
| 1299 | 1302 |
/// \ref concepts::Digraph "Digraph" or \ref concepts::Graph "Graph" |
| 1300 | 1303 |
/// concept. |
| 1301 | 1304 |
/// |
| 1302 | 1305 |
/// This implementation is slightly faster than the \c ListEdgeSet, |
| 1303 | 1306 |
/// because it uses continuous storage for edges and it uses just |
| 1304 | 1307 |
/// single-linked lists for enumerate incident edges. Therefore the |
| 1305 | 1308 |
/// edges cannot be erased from the edge sets. |
| 1306 | 1309 |
/// |
| 1310 |
/// This class fully conforms to the \ref concepts::Graph "Graph" |
|
| 1311 |
/// concept. |
|
| 1312 |
/// It provides only linear time counting for nodes, edges and arcs. |
|
| 1313 |
/// |
|
| 1307 | 1314 |
/// \warning If a node is erased from the underlying graph and this |
| 1308 | 1315 |
/// node is incident to one edge in the edge set, then the edge set |
| 1309 | 1316 |
/// is invalidated, and it cannot be used anymore. The validity can |
| 1310 | 1317 |
/// be checked with the \c valid() member function. |
| 1311 |
/// |
|
| 1312 |
/// This class fully conforms to the \ref concepts::Graph |
|
| 1313 |
/// "Graph" concept. |
|
| 1314 | 1318 |
template <typename GR> |
| 1315 | 1319 |
class SmartEdgeSet : public EdgeSetExtender<SmartEdgeSetBase<GR> > {
|
| 1316 | 1320 |
typedef EdgeSetExtender<SmartEdgeSetBase<GR> > Parent; |
| 1317 | 1321 |
|
| 1318 | 1322 |
public: |
| 1319 | 1323 |
|
| 1320 | 1324 |
typedef typename Parent::Node Node; |
| 1321 | 1325 |
typedef typename Parent::Arc Arc; |
| 1322 | 1326 |
typedef typename Parent::Edge Edge; |
| 1323 | 1327 |
|
| 1324 | 1328 |
protected: |
| 1325 | 1329 |
| ... | ... |
@@ -153,24 +153,26 @@ |
| 153 | 153 |
/// FullDigraph is a simple and fast implmenetation of directed full |
| 154 | 154 |
/// (complete) graphs. It contains an arc from each node to each node |
| 155 | 155 |
/// (including a loop for each node), therefore the number of arcs |
| 156 | 156 |
/// is the square of the number of nodes. |
| 157 | 157 |
/// This class is completely static and it needs constant memory space. |
| 158 | 158 |
/// Thus you can neither add nor delete nodes or arcs, however |
| 159 | 159 |
/// the structure can be resized using resize(). |
| 160 | 160 |
/// |
| 161 | 161 |
/// This type fully conforms to the \ref concepts::Digraph "Digraph concept". |
| 162 | 162 |
/// Most of its member functions and nested classes are documented |
| 163 | 163 |
/// only in the concept class. |
| 164 | 164 |
/// |
| 165 |
/// This class provides constant time counting for nodes and arcs. |
|
| 166 |
/// |
|
| 165 | 167 |
/// \note FullDigraph and FullGraph classes are very similar, |
| 166 | 168 |
/// but there are two differences. While this class conforms only |
| 167 | 169 |
/// to the \ref concepts::Digraph "Digraph" concept, FullGraph |
| 168 | 170 |
/// conforms to the \ref concepts::Graph "Graph" concept, |
| 169 | 171 |
/// moreover FullGraph does not contain a loop for each |
| 170 | 172 |
/// node as this class does. |
| 171 | 173 |
/// |
| 172 | 174 |
/// \sa FullGraph |
| 173 | 175 |
class FullDigraph : public ExtendedFullDigraphBase {
|
| 174 | 176 |
typedef ExtendedFullDigraphBase Parent; |
| 175 | 177 |
|
| 176 | 178 |
public: |
| ... | ... |
@@ -195,32 +197,34 @@ |
| 195 | 197 |
Parent::notifier(Arc()).clear(); |
| 196 | 198 |
Parent::notifier(Node()).clear(); |
| 197 | 199 |
construct(n); |
| 198 | 200 |
Parent::notifier(Node()).build(); |
| 199 | 201 |
Parent::notifier(Arc()).build(); |
| 200 | 202 |
} |
| 201 | 203 |
|
| 202 | 204 |
/// \brief Returns the node with the given index. |
| 203 | 205 |
/// |
| 204 | 206 |
/// Returns the node with the given index. Since this structure is |
| 205 | 207 |
/// completely static, the nodes can be indexed with integers from |
| 206 | 208 |
/// the range <tt>[0..nodeNum()-1]</tt>. |
| 209 |
/// The index of a node is the same as its ID. |
|
| 207 | 210 |
/// \sa index() |
| 208 | 211 |
Node operator()(int ix) const { return Parent::operator()(ix); }
|
| 209 | 212 |
|
| 210 | 213 |
/// \brief Returns the index of the given node. |
| 211 | 214 |
/// |
| 212 | 215 |
/// Returns the index of the given node. Since this structure is |
| 213 | 216 |
/// completely static, the nodes can be indexed with integers from |
| 214 | 217 |
/// the range <tt>[0..nodeNum()-1]</tt>. |
| 218 |
/// The index of a node is the same as its ID. |
|
| 215 | 219 |
/// \sa operator()() |
| 216 | 220 |
static int index(const Node& node) { return Parent::index(node); }
|
| 217 | 221 |
|
| 218 | 222 |
/// \brief Returns the arc connecting the given nodes. |
| 219 | 223 |
/// |
| 220 | 224 |
/// Returns the arc connecting the given nodes. |
| 221 | 225 |
Arc arc(Node u, Node v) const {
|
| 222 | 226 |
return Parent::arc(u, v); |
| 223 | 227 |
} |
| 224 | 228 |
|
| 225 | 229 |
/// \brief Number of nodes. |
| 226 | 230 |
int nodeNum() const { return Parent::nodeNum(); }
|
| ... | ... |
@@ -526,24 +530,26 @@ |
| 526 | 530 |
/// |
| 527 | 531 |
/// FullGraph is a simple and fast implmenetation of undirected full |
| 528 | 532 |
/// (complete) graphs. It contains an edge between every distinct pair |
| 529 | 533 |
/// of nodes, therefore the number of edges is <tt>n(n-1)/2</tt>. |
| 530 | 534 |
/// This class is completely static and it needs constant memory space. |
| 531 | 535 |
/// Thus you can neither add nor delete nodes or edges, however |
| 532 | 536 |
/// the structure can be resized using resize(). |
| 533 | 537 |
/// |
| 534 | 538 |
/// This type fully conforms to the \ref concepts::Graph "Graph concept". |
| 535 | 539 |
/// Most of its member functions and nested classes are documented |
| 536 | 540 |
/// only in the concept class. |
| 537 | 541 |
/// |
| 542 |
/// This class provides constant time counting for nodes, edges and arcs. |
|
| 543 |
/// |
|
| 538 | 544 |
/// \note FullDigraph and FullGraph classes are very similar, |
| 539 | 545 |
/// but there are two differences. While FullDigraph |
| 540 | 546 |
/// conforms only to the \ref concepts::Digraph "Digraph" concept, |
| 541 | 547 |
/// this class conforms to the \ref concepts::Graph "Graph" concept, |
| 542 | 548 |
/// moreover this class does not contain a loop for each |
| 543 | 549 |
/// node as FullDigraph does. |
| 544 | 550 |
/// |
| 545 | 551 |
/// \sa FullDigraph |
| 546 | 552 |
class FullGraph : public ExtendedFullGraphBase {
|
| 547 | 553 |
typedef ExtendedFullGraphBase Parent; |
| 548 | 554 |
|
| 549 | 555 |
public: |
| ... | ... |
@@ -570,32 +576,34 @@ |
| 570 | 576 |
Parent::notifier(Node()).clear(); |
| 571 | 577 |
construct(n); |
| 572 | 578 |
Parent::notifier(Node()).build(); |
| 573 | 579 |
Parent::notifier(Edge()).build(); |
| 574 | 580 |
Parent::notifier(Arc()).build(); |
| 575 | 581 |
} |
| 576 | 582 |
|
| 577 | 583 |
/// \brief Returns the node with the given index. |
| 578 | 584 |
/// |
| 579 | 585 |
/// Returns the node with the given index. Since this structure is |
| 580 | 586 |
/// completely static, the nodes can be indexed with integers from |
| 581 | 587 |
/// the range <tt>[0..nodeNum()-1]</tt>. |
| 588 |
/// The index of a node is the same as its ID. |
|
| 582 | 589 |
/// \sa index() |
| 583 | 590 |
Node operator()(int ix) const { return Parent::operator()(ix); }
|
| 584 | 591 |
|
| 585 | 592 |
/// \brief Returns the index of the given node. |
| 586 | 593 |
/// |
| 587 | 594 |
/// Returns the index of the given node. Since this structure is |
| 588 | 595 |
/// completely static, the nodes can be indexed with integers from |
| 589 | 596 |
/// the range <tt>[0..nodeNum()-1]</tt>. |
| 597 |
/// The index of a node is the same as its ID. |
|
| 590 | 598 |
/// \sa operator()() |
| 591 | 599 |
static int index(const Node& node) { return Parent::index(node); }
|
| 592 | 600 |
|
| 593 | 601 |
/// \brief Returns the arc connecting the given nodes. |
| 594 | 602 |
/// |
| 595 | 603 |
/// Returns the arc connecting the given nodes. |
| 596 | 604 |
Arc arc(Node s, Node t) const {
|
| 597 | 605 |
return Parent::arc(s, t); |
| 598 | 606 |
} |
| 599 | 607 |
|
| 600 | 608 |
/// \brief Returns the edge connecting the given nodes. |
| 601 | 609 |
/// |
| ... | ... |
@@ -494,24 +494,26 @@ |
| 494 | 494 |
/// GridGraph graph(rows, cols); |
| 495 | 495 |
/// GridGraph::NodeMap<int> val(graph); |
| 496 | 496 |
/// for (int i = 0; i < graph.width(); ++i) {
|
| 497 | 497 |
/// for (int j = 0; j < graph.height(); ++j) {
|
| 498 | 498 |
/// val[graph(i, j)] = i + j; |
| 499 | 499 |
/// } |
| 500 | 500 |
/// } |
| 501 | 501 |
///\endcode |
| 502 | 502 |
/// |
| 503 | 503 |
/// This type fully conforms to the \ref concepts::Graph "Graph concept". |
| 504 | 504 |
/// Most of its member functions and nested classes are documented |
| 505 | 505 |
/// only in the concept class. |
| 506 |
/// |
|
| 507 |
/// This class provides constant time counting for nodes, edges and arcs. |
|
| 506 | 508 |
class GridGraph : public ExtendedGridGraphBase {
|
| 507 | 509 |
typedef ExtendedGridGraphBase Parent; |
| 508 | 510 |
|
| 509 | 511 |
public: |
| 510 | 512 |
|
| 511 | 513 |
/// \brief Map to get the indices of the nodes as \ref dim2::Point |
| 512 | 514 |
/// "dim2::Point<int>". |
| 513 | 515 |
/// |
| 514 | 516 |
/// Map to get the indices of the nodes as \ref dim2::Point |
| 515 | 517 |
/// "dim2::Point<int>". |
| 516 | 518 |
class IndexMap {
|
| 517 | 519 |
public: |
| ... | ... |
@@ -285,24 +285,26 @@ |
| 285 | 285 |
/// HypercubeGraph implements a special graph type. The nodes of the |
| 286 | 286 |
/// graph are indexed with integers having at most \c dim binary digits. |
| 287 | 287 |
/// Two nodes are connected in the graph if and only if their indices |
| 288 | 288 |
/// differ only on one position in the binary form. |
| 289 | 289 |
/// This class is completely static and it needs constant memory space. |
| 290 | 290 |
/// Thus you can neither add nor delete nodes or edges, however |
| 291 | 291 |
/// the structure can be resized using resize(). |
| 292 | 292 |
/// |
| 293 | 293 |
/// This type fully conforms to the \ref concepts::Graph "Graph concept". |
| 294 | 294 |
/// Most of its member functions and nested classes are documented |
| 295 | 295 |
/// only in the concept class. |
| 296 | 296 |
/// |
| 297 |
/// This class provides constant time counting for nodes, edges and arcs. |
|
| 298 |
/// |
|
| 297 | 299 |
/// \note The type of the indices is chosen to \c int for efficiency |
| 298 | 300 |
/// reasons. Thus the maximum dimension of this implementation is 26 |
| 299 | 301 |
/// (assuming that the size of \c int is 32 bit). |
| 300 | 302 |
class HypercubeGraph : public ExtendedHypercubeGraphBase {
|
| 301 | 303 |
typedef ExtendedHypercubeGraphBase Parent; |
| 302 | 304 |
|
| 303 | 305 |
public: |
| 304 | 306 |
|
| 305 | 307 |
/// \brief Constructs a hypercube graph with \c dim dimensions. |
| 306 | 308 |
/// |
| 307 | 309 |
/// Constructs a hypercube graph with \c dim dimensions. |
| 308 | 310 |
HypercubeGraph(int dim) { construct(dim); }
|
| ... | ... |
@@ -315,24 +315,26 @@ |
| 315 | 315 |
|
| 316 | 316 |
///A general directed graph structure. |
| 317 | 317 |
|
| 318 | 318 |
///\ref ListDigraph is a versatile and fast directed graph |
| 319 | 319 |
///implementation based on linked lists that are stored in |
| 320 | 320 |
///\c std::vector structures. |
| 321 | 321 |
/// |
| 322 | 322 |
///This type fully conforms to the \ref concepts::Digraph "Digraph concept" |
| 323 | 323 |
///and it also provides several useful additional functionalities. |
| 324 | 324 |
///Most of its member functions and nested classes are documented |
| 325 | 325 |
///only in the concept class. |
| 326 | 326 |
/// |
| 327 |
///This class provides only linear time counting for nodes and arcs. |
|
| 328 |
/// |
|
| 327 | 329 |
///\sa concepts::Digraph |
| 328 | 330 |
///\sa ListGraph |
| 329 | 331 |
class ListDigraph : public ExtendedListDigraphBase {
|
| 330 | 332 |
typedef ExtendedListDigraphBase Parent; |
| 331 | 333 |
|
| 332 | 334 |
private: |
| 333 | 335 |
/// Digraphs are \e not copy constructible. Use DigraphCopy instead. |
| 334 | 336 |
ListDigraph(const ListDigraph &) :ExtendedListDigraphBase() {};
|
| 335 | 337 |
/// \brief Assignment of a digraph to another one is \e not allowed. |
| 336 | 338 |
/// Use DigraphCopy instead. |
| 337 | 339 |
void operator=(const ListDigraph &) {}
|
| 338 | 340 |
public: |
| ... | ... |
@@ -351,30 +353,37 @@ |
| 351 | 353 |
|
| 352 | 354 |
///Add a new arc to the digraph. |
| 353 | 355 |
|
| 354 | 356 |
///This function adds a new arc to the digraph with source node \c s |
| 355 | 357 |
///and target node \c t. |
| 356 | 358 |
///\return The new arc. |
| 357 | 359 |
Arc addArc(Node s, Node t) {
|
| 358 | 360 |
return Parent::addArc(s, t); |
| 359 | 361 |
} |
| 360 | 362 |
|
| 361 | 363 |
///\brief Erase a node from the digraph. |
| 362 | 364 |
/// |
| 363 |
///This function erases the given node |
|
| 365 |
///This function erases the given node along with its outgoing and |
|
| 366 |
///incoming arcs from the digraph. |
|
| 367 |
/// |
|
| 368 |
///\note All iterators referencing the removed node or the connected |
|
| 369 |
///arcs are invalidated, of course. |
|
| 364 | 370 |
void erase(Node n) { Parent::erase(n); }
|
| 365 | 371 |
|
| 366 | 372 |
///\brief Erase an arc from the digraph. |
| 367 | 373 |
/// |
| 368 | 374 |
///This function erases the given arc from the digraph. |
| 375 |
/// |
|
| 376 |
///\note All iterators referencing the removed arc are invalidated, |
|
| 377 |
///of course. |
|
| 369 | 378 |
void erase(Arc a) { Parent::erase(a); }
|
| 370 | 379 |
|
| 371 | 380 |
/// Node validity check |
| 372 | 381 |
|
| 373 | 382 |
/// This function gives back \c true if the given node is valid, |
| 374 | 383 |
/// i.e. it is a real node of the digraph. |
| 375 | 384 |
/// |
| 376 | 385 |
/// \warning A removed node could become valid again if new nodes are |
| 377 | 386 |
/// added to the digraph. |
| 378 | 387 |
bool valid(Node n) const { return Parent::valid(n); }
|
| 379 | 388 |
|
| 380 | 389 |
/// Arc validity check |
| ... | ... |
@@ -501,24 +510,25 @@ |
| 501 | 510 |
///Snapshot feature. |
| 502 | 511 |
Node split(Arc a) {
|
| 503 | 512 |
Node v = addNode(); |
| 504 | 513 |
addArc(v,target(a)); |
| 505 | 514 |
changeTarget(a,v); |
| 506 | 515 |
return v; |
| 507 | 516 |
} |
| 508 | 517 |
|
| 509 | 518 |
///Clear the digraph. |
| 510 | 519 |
|
| 511 | 520 |
///This function erases all nodes and arcs from the digraph. |
| 512 | 521 |
/// |
| 522 |
///\note All iterators of the digraph are invalidated, of course. |
|
| 513 | 523 |
void clear() {
|
| 514 | 524 |
Parent::clear(); |
| 515 | 525 |
} |
| 516 | 526 |
|
| 517 | 527 |
/// Reserve memory for nodes. |
| 518 | 528 |
|
| 519 | 529 |
/// Using this function, it is possible to avoid superfluous memory |
| 520 | 530 |
/// allocation: if you know that the digraph you want to build will |
| 521 | 531 |
/// be large (e.g. it will contain millions of nodes and/or arcs), |
| 522 | 532 |
/// then it is worth reserving space for this amount before starting |
| 523 | 533 |
/// to build the digraph. |
| 524 | 534 |
/// \sa reserveArc() |
| ... | ... |
@@ -1170,24 +1180,26 @@ |
| 1170 | 1180 |
|
| 1171 | 1181 |
///A general undirected graph structure. |
| 1172 | 1182 |
|
| 1173 | 1183 |
///\ref ListGraph is a versatile and fast undirected graph |
| 1174 | 1184 |
///implementation based on linked lists that are stored in |
| 1175 | 1185 |
///\c std::vector structures. |
| 1176 | 1186 |
/// |
| 1177 | 1187 |
///This type fully conforms to the \ref concepts::Graph "Graph concept" |
| 1178 | 1188 |
///and it also provides several useful additional functionalities. |
| 1179 | 1189 |
///Most of its member functions and nested classes are documented |
| 1180 | 1190 |
///only in the concept class. |
| 1181 | 1191 |
/// |
| 1192 |
///This class provides only linear time counting for nodes, edges and arcs. |
|
| 1193 |
/// |
|
| 1182 | 1194 |
///\sa concepts::Graph |
| 1183 | 1195 |
///\sa ListDigraph |
| 1184 | 1196 |
class ListGraph : public ExtendedListGraphBase {
|
| 1185 | 1197 |
typedef ExtendedListGraphBase Parent; |
| 1186 | 1198 |
|
| 1187 | 1199 |
private: |
| 1188 | 1200 |
/// Graphs are \e not copy constructible. Use GraphCopy instead. |
| 1189 | 1201 |
ListGraph(const ListGraph &) :ExtendedListGraphBase() {};
|
| 1190 | 1202 |
/// \brief Assignment of a graph to another one is \e not allowed. |
| 1191 | 1203 |
/// Use GraphCopy instead. |
| 1192 | 1204 |
void operator=(const ListGraph &) {}
|
| 1193 | 1205 |
public: |
| ... | ... |
@@ -1208,30 +1220,37 @@ |
| 1208 | 1220 |
/// \brief Add a new edge to the graph. |
| 1209 | 1221 |
/// |
| 1210 | 1222 |
/// This function adds a new edge to the graph between nodes |
| 1211 | 1223 |
/// \c u and \c v with inherent orientation from node \c u to |
| 1212 | 1224 |
/// node \c v. |
| 1213 | 1225 |
/// \return The new edge. |
| 1214 | 1226 |
Edge addEdge(Node u, Node v) {
|
| 1215 | 1227 |
return Parent::addEdge(u, v); |
| 1216 | 1228 |
} |
| 1217 | 1229 |
|
| 1218 | 1230 |
///\brief Erase a node from the graph. |
| 1219 | 1231 |
/// |
| 1220 |
/// This function erases the given node |
|
| 1232 |
/// This function erases the given node along with its incident arcs |
|
| 1233 |
/// from the graph. |
|
| 1234 |
/// |
|
| 1235 |
/// \note All iterators referencing the removed node or the incident |
|
| 1236 |
/// edges are invalidated, of course. |
|
| 1221 | 1237 |
void erase(Node n) { Parent::erase(n); }
|
| 1222 | 1238 |
|
| 1223 | 1239 |
///\brief Erase an edge from the graph. |
| 1224 | 1240 |
/// |
| 1225 | 1241 |
/// This function erases the given edge from the graph. |
| 1242 |
/// |
|
| 1243 |
/// \note All iterators referencing the removed edge are invalidated, |
|
| 1244 |
/// of course. |
|
| 1226 | 1245 |
void erase(Edge e) { Parent::erase(e); }
|
| 1227 | 1246 |
/// Node validity check |
| 1228 | 1247 |
|
| 1229 | 1248 |
/// This function gives back \c true if the given node is valid, |
| 1230 | 1249 |
/// i.e. it is a real node of the graph. |
| 1231 | 1250 |
/// |
| 1232 | 1251 |
/// \warning A removed node could become valid again if new nodes are |
| 1233 | 1252 |
/// added to the graph. |
| 1234 | 1253 |
bool valid(Node n) const { return Parent::valid(n); }
|
| 1235 | 1254 |
/// Edge validity check |
| 1236 | 1255 |
|
| 1237 | 1256 |
/// This function gives back \c true if the given edge is valid, |
| ... | ... |
@@ -1303,24 +1322,25 @@ |
| 1303 | 1322 |
} else {
|
| 1304 | 1323 |
changeV(e, a); |
| 1305 | 1324 |
} |
| 1306 | 1325 |
e = f; |
| 1307 | 1326 |
} |
| 1308 | 1327 |
erase(b); |
| 1309 | 1328 |
} |
| 1310 | 1329 |
|
| 1311 | 1330 |
///Clear the graph. |
| 1312 | 1331 |
|
| 1313 | 1332 |
///This function erases all nodes and arcs from the graph. |
| 1314 | 1333 |
/// |
| 1334 |
///\note All iterators of the graph are invalidated, of course. |
|
| 1315 | 1335 |
void clear() {
|
| 1316 | 1336 |
Parent::clear(); |
| 1317 | 1337 |
} |
| 1318 | 1338 |
|
| 1319 | 1339 |
/// Reserve memory for nodes. |
| 1320 | 1340 |
|
| 1321 | 1341 |
/// Using this function, it is possible to avoid superfluous memory |
| 1322 | 1342 |
/// allocation: if you know that the graph you want to build will |
| 1323 | 1343 |
/// be large (e.g. it will contain millions of nodes and/or edges), |
| 1324 | 1344 |
/// then it is worth reserving space for this amount before starting |
| 1325 | 1345 |
/// to build the graph. |
| 1326 | 1346 |
/// \sa reserveEdge() |
| ... | ... |
@@ -185,24 +185,26 @@ |
| 185 | 185 |
///\brief A smart directed graph class. |
| 186 | 186 |
/// |
| 187 | 187 |
///\ref SmartDigraph is a simple and fast digraph implementation. |
| 188 | 188 |
///It is also quite memory efficient but at the price |
| 189 | 189 |
///that it does not support node and arc deletion |
| 190 | 190 |
///(except for the Snapshot feature). |
| 191 | 191 |
/// |
| 192 | 192 |
///This type fully conforms to the \ref concepts::Digraph "Digraph concept" |
| 193 | 193 |
///and it also provides some additional functionalities. |
| 194 | 194 |
///Most of its member functions and nested classes are documented |
| 195 | 195 |
///only in the concept class. |
| 196 | 196 |
/// |
| 197 |
///This class provides constant time counting for nodes and arcs. |
|
| 198 |
/// |
|
| 197 | 199 |
///\sa concepts::Digraph |
| 198 | 200 |
///\sa SmartGraph |
| 199 | 201 |
class SmartDigraph : public ExtendedSmartDigraphBase {
|
| 200 | 202 |
typedef ExtendedSmartDigraphBase Parent; |
| 201 | 203 |
|
| 202 | 204 |
private: |
| 203 | 205 |
/// Digraphs are \e not copy constructible. Use DigraphCopy instead. |
| 204 | 206 |
SmartDigraph(const SmartDigraph &) : ExtendedSmartDigraphBase() {};
|
| 205 | 207 |
/// \brief Assignment of a digraph to another one is \e not allowed. |
| 206 | 208 |
/// Use DigraphCopy instead. |
| 207 | 209 |
void operator=(const SmartDigraph &) {}
|
| 208 | 210 |
|
| ... | ... |
@@ -611,24 +613,26 @@ |
| 611 | 613 |
/// \brief A smart undirected graph class. |
| 612 | 614 |
/// |
| 613 | 615 |
/// \ref SmartGraph is a simple and fast graph implementation. |
| 614 | 616 |
/// It is also quite memory efficient but at the price |
| 615 | 617 |
/// that it does not support node and edge deletion |
| 616 | 618 |
/// (except for the Snapshot feature). |
| 617 | 619 |
/// |
| 618 | 620 |
/// This type fully conforms to the \ref concepts::Graph "Graph concept" |
| 619 | 621 |
/// and it also provides some additional functionalities. |
| 620 | 622 |
/// Most of its member functions and nested classes are documented |
| 621 | 623 |
/// only in the concept class. |
| 622 | 624 |
/// |
| 625 |
/// This class provides constant time counting for nodes, edges and arcs. |
|
| 626 |
/// |
|
| 623 | 627 |
/// \sa concepts::Graph |
| 624 | 628 |
/// \sa SmartDigraph |
| 625 | 629 |
class SmartGraph : public ExtendedSmartGraphBase {
|
| 626 | 630 |
typedef ExtendedSmartGraphBase Parent; |
| 627 | 631 |
|
| 628 | 632 |
private: |
| 629 | 633 |
/// Graphs are \e not copy constructible. Use GraphCopy instead. |
| 630 | 634 |
SmartGraph(const SmartGraph &) : ExtendedSmartGraphBase() {};
|
| 631 | 635 |
/// \brief Assignment of a graph to another one is \e not allowed. |
| 632 | 636 |
/// Use GraphCopy instead. |
| 633 | 637 |
void operator=(const SmartGraph &) {}
|
| 634 | 638 |
| ... | ... |
@@ -283,24 +283,26 @@ |
| 283 | 283 |
/// Since this digraph structure is completely static, its nodes and arcs |
| 284 | 284 |
/// can be indexed with integers from the ranges <tt>[0..nodeNum()-1]</tt> |
| 285 | 285 |
/// and <tt>[0..arcNum()-1]</tt>, respectively. |
| 286 | 286 |
/// The index of an item is the same as its ID, it can be obtained |
| 287 | 287 |
/// using the corresponding \ref index() or \ref concepts::Digraph::id() |
| 288 | 288 |
/// "id()" function. A node or arc with a certain index can be obtained |
| 289 | 289 |
/// using node() or arc(). |
| 290 | 290 |
/// |
| 291 | 291 |
/// This type fully conforms to the \ref concepts::Digraph "Digraph concept". |
| 292 | 292 |
/// Most of its member functions and nested classes are documented |
| 293 | 293 |
/// only in the concept class. |
| 294 | 294 |
/// |
| 295 |
/// This class provides constant time counting for nodes and arcs. |
|
| 296 |
/// |
|
| 295 | 297 |
/// \sa concepts::Digraph |
| 296 | 298 |
class StaticDigraph : public ExtendedStaticDigraphBase {
|
| 297 | 299 |
public: |
| 298 | 300 |
|
| 299 | 301 |
typedef ExtendedStaticDigraphBase Parent; |
| 300 | 302 |
|
| 301 | 303 |
public: |
| 302 | 304 |
|
| 303 | 305 |
/// \brief Constructor |
| 304 | 306 |
/// |
| 305 | 307 |
/// Default constructor. |
| 306 | 308 |
StaticDigraph() : Parent() {}
|
0 comments (0 inline)