| ... | ... |
@@ -102,25 +102,25 @@ |
| 102 | 102 |
/// |
| 103 | 103 |
/// The algorithm calculates an optimal fractional matching and a |
| 104 | 104 |
/// barrier. The number of adjacents of any node set minus the size |
| 105 | 105 |
/// of node set is a lower bound on the uncovered nodes in the |
| 106 | 106 |
/// graph. For maximum matching a barrier is computed which |
| 107 | 107 |
/// maximizes this difference. |
| 108 | 108 |
/// |
| 109 | 109 |
/// The algorithm can be executed with the run() function. After it |
| 110 | 110 |
/// the matching (the primal solution) and the barrier (the dual |
| 111 | 111 |
/// solution) can be obtained using the query functions. |
| 112 | 112 |
/// |
| 113 | 113 |
/// The primal solution is multiplied by |
| 114 |
/// \ref |
|
| 114 |
/// \ref MaxFractionalMatching::primalScale "2". |
|
| 115 | 115 |
/// |
| 116 | 116 |
/// \tparam GR The undirected graph type the algorithm runs on. |
| 117 | 117 |
#ifdef DOXYGEN |
| 118 | 118 |
template <typename GR, typename TR> |
| 119 | 119 |
#else |
| 120 | 120 |
template <typename GR, |
| 121 | 121 |
typename TR = MaxFractionalMatchingDefaultTraits<GR> > |
| 122 | 122 |
#endif |
| 123 | 123 |
class MaxFractionalMatching {
|
| 124 | 124 |
public: |
| 125 | 125 |
|
| 126 | 126 |
/// \brief The \ref MaxFractionalMatchingDefaultTraits "traits |
| ... | ... |
@@ -623,55 +623,54 @@ |
| 623 | 623 |
return (*_level)[node] >= _empty_level; |
| 624 | 624 |
} |
| 625 | 625 |
|
| 626 | 626 |
/// @} |
| 627 | 627 |
|
| 628 | 628 |
}; |
| 629 | 629 |
|
| 630 | 630 |
/// \ingroup matching |
| 631 | 631 |
/// |
| 632 | 632 |
/// \brief Weighted fractional matching in general graphs |
| 633 | 633 |
/// |
| 634 | 634 |
/// This class provides an efficient implementation of fractional |
| 635 |
/// matching algorithm. The implementation is based on extensive use |
|
| 636 |
/// of priority queues and provides \f$O(nm\log n)\f$ time |
|
| 637 |
/// |
|
| 635 |
/// matching algorithm. The implementation uses priority queues and |
|
| 636 |
/// provides \f$O(nm\log n)\f$ time complexity. |
|
| 638 | 637 |
/// |
| 639 | 638 |
/// The maximum weighted fractional matching is a relaxation of the |
| 640 | 639 |
/// maximum weighted matching problem where the odd set constraints |
| 641 | 640 |
/// are omitted. |
| 642 | 641 |
/// It can be formulated with the following linear program. |
| 643 | 642 |
/// \f[ \sum_{e \in \delta(u)}x_e \le 1 \quad \forall u\in V\f]
|
| 644 | 643 |
/// \f[x_e \ge 0\quad \forall e\in E\f] |
| 645 | 644 |
/// \f[\max \sum_{e\in E}x_ew_e\f]
|
| 646 | 645 |
/// where \f$\delta(X)\f$ is the set of edges incident to a node in |
| 647 | 646 |
/// \f$X\f$. The result must be the union of a matching with one |
| 648 | 647 |
/// value edges and a set of odd length cycles with half value edges. |
| 649 | 648 |
/// |
| 650 | 649 |
/// The algorithm calculates an optimal fractional matching and a |
| 651 | 650 |
/// proof of the optimality. The solution of the dual problem can be |
| 652 | 651 |
/// used to check the result of the algorithm. The dual linear |
| 653 | 652 |
/// problem is the following. |
| 654 | 653 |
/// \f[ y_u + y_v \ge w_{uv} \quad \forall uv\in E\f]
|
| 655 | 654 |
/// \f[y_u \ge 0 \quad \forall u \in V\f] |
| 656 |
/// \f[\min \sum_{u \in V}y_u \f]
|
|
| 655 |
/// \f[\min \sum_{u \in V}y_u \f]
|
|
| 657 | 656 |
/// |
| 658 | 657 |
/// The algorithm can be executed with the run() function. |
| 659 | 658 |
/// After it the matching (the primal solution) and the dual solution |
| 660 | 659 |
/// can be obtained using the query functions. |
| 661 | 660 |
/// |
| 662 | 661 |
/// If the value type is integer, then the primal and the dual |
| 663 | 662 |
/// solutions are multiplied by |
| 664 |
/// \ref MaxWeightedMatching::primalScale "2" and |
|
| 665 |
/// \ref MaxWeightedMatching::dualScale "4" respectively. |
|
| 663 |
/// \ref MaxWeightedFractionalMatching::primalScale "2" and |
|
| 664 |
/// \ref MaxWeightedFractionalMatching::dualScale "4" respectively. |
|
| 666 | 665 |
/// |
| 667 | 666 |
/// \tparam GR The undirected graph type the algorithm runs on. |
| 668 | 667 |
/// \tparam WM The type edge weight map. The default type is |
| 669 | 668 |
/// \ref concepts::Graph::EdgeMap "GR::EdgeMap<int>". |
| 670 | 669 |
#ifdef DOXYGEN |
| 671 | 670 |
template <typename GR, typename WM> |
| 672 | 671 |
#else |
| 673 | 672 |
template <typename GR, |
| 674 | 673 |
typename WM = typename GR::template EdgeMap<int> > |
| 675 | 674 |
#endif |
| 676 | 675 |
class MaxWeightedFractionalMatching {
|
| 677 | 676 |
public: |
| ... | ... |
@@ -1261,25 +1260,25 @@ |
| 1261 | 1260 |
--unmatched; |
| 1262 | 1261 |
} else {
|
| 1263 | 1262 |
augmentOnEdge(e); |
| 1264 | 1263 |
unmatched -= 2; |
| 1265 | 1264 |
} |
| 1266 | 1265 |
} break; |
| 1267 | 1266 |
} |
| 1268 | 1267 |
} |
| 1269 | 1268 |
} |
| 1270 | 1269 |
|
| 1271 | 1270 |
/// \brief Run the algorithm. |
| 1272 | 1271 |
/// |
| 1273 |
/// This method runs the \c % |
|
| 1272 |
/// This method runs the \c %MaxWeightedFractionalMatching algorithm. |
|
| 1274 | 1273 |
/// |
| 1275 | 1274 |
/// \note mwfm.run() is just a shortcut of the following code. |
| 1276 | 1275 |
/// \code |
| 1277 | 1276 |
/// mwfm.init(); |
| 1278 | 1277 |
/// mwfm.start(); |
| 1279 | 1278 |
/// \endcode |
| 1280 | 1279 |
void run() {
|
| 1281 | 1280 |
init(); |
| 1282 | 1281 |
start(); |
| 1283 | 1282 |
} |
| 1284 | 1283 |
|
| 1285 | 1284 |
/// @} |
| ... | ... |
@@ -1391,54 +1390,53 @@ |
| 1391 | 1390 |
return (*_node_potential)[n]; |
| 1392 | 1391 |
} |
| 1393 | 1392 |
|
| 1394 | 1393 |
/// @} |
| 1395 | 1394 |
|
| 1396 | 1395 |
}; |
| 1397 | 1396 |
|
| 1398 | 1397 |
/// \ingroup matching |
| 1399 | 1398 |
/// |
| 1400 | 1399 |
/// \brief Weighted fractional perfect matching in general graphs |
| 1401 | 1400 |
/// |
| 1402 | 1401 |
/// This class provides an efficient implementation of fractional |
| 1403 |
/// matching algorithm. The implementation is based on extensive use |
|
| 1404 |
/// of priority queues and provides \f$O(nm\log n)\f$ time |
|
| 1405 |
/// |
|
| 1402 |
/// matching algorithm. The implementation uses priority queues and |
|
| 1403 |
/// provides \f$O(nm\log n)\f$ time complexity. |
|
| 1406 | 1404 |
/// |
| 1407 | 1405 |
/// The maximum weighted fractional perfect matching is a relaxation |
| 1408 | 1406 |
/// of the maximum weighted perfect matching problem where the odd |
| 1409 | 1407 |
/// set constraints are omitted. |
| 1410 | 1408 |
/// It can be formulated with the following linear program. |
| 1411 | 1409 |
/// \f[ \sum_{e \in \delta(u)}x_e = 1 \quad \forall u\in V\f]
|
| 1412 | 1410 |
/// \f[x_e \ge 0\quad \forall e\in E\f] |
| 1413 | 1411 |
/// \f[\max \sum_{e\in E}x_ew_e\f]
|
| 1414 | 1412 |
/// where \f$\delta(X)\f$ is the set of edges incident to a node in |
| 1415 | 1413 |
/// \f$X\f$. The result must be the union of a matching with one |
| 1416 | 1414 |
/// value edges and a set of odd length cycles with half value edges. |
| 1417 | 1415 |
/// |
| 1418 | 1416 |
/// The algorithm calculates an optimal fractional matching and a |
| 1419 | 1417 |
/// proof of the optimality. The solution of the dual problem can be |
| 1420 | 1418 |
/// used to check the result of the algorithm. The dual linear |
| 1421 | 1419 |
/// problem is the following. |
| 1422 | 1420 |
/// \f[ y_u + y_v \ge w_{uv} \quad \forall uv\in E\f]
|
| 1423 |
/// \f[\min \sum_{u \in V}y_u \f]
|
|
| 1421 |
/// \f[\min \sum_{u \in V}y_u \f]
|
|
| 1424 | 1422 |
/// |
| 1425 | 1423 |
/// The algorithm can be executed with the run() function. |
| 1426 | 1424 |
/// After it the matching (the primal solution) and the dual solution |
| 1427 | 1425 |
/// can be obtained using the query functions. |
| 1428 | 1426 |
|
| 1429 | 1427 |
/// If the value type is integer, then the primal and the dual |
| 1430 | 1428 |
/// solutions are multiplied by |
| 1431 |
/// \ref MaxWeightedMatching::primalScale "2" and |
|
| 1432 |
/// \ref MaxWeightedMatching::dualScale "4" respectively. |
|
| 1429 |
/// \ref MaxWeightedPerfectFractionalMatching::primalScale "2" and |
|
| 1430 |
/// \ref MaxWeightedPerfectFractionalMatching::dualScale "4" respectively. |
|
| 1433 | 1431 |
/// |
| 1434 | 1432 |
/// \tparam GR The undirected graph type the algorithm runs on. |
| 1435 | 1433 |
/// \tparam WM The type edge weight map. The default type is |
| 1436 | 1434 |
/// \ref concepts::Graph::EdgeMap "GR::EdgeMap<int>". |
| 1437 | 1435 |
#ifdef DOXYGEN |
| 1438 | 1436 |
template <typename GR, typename WM> |
| 1439 | 1437 |
#else |
| 1440 | 1438 |
template <typename GR, |
| 1441 | 1439 |
typename WM = typename GR::template EdgeMap<int> > |
| 1442 | 1440 |
#endif |
| 1443 | 1441 |
class MaxWeightedPerfectFractionalMatching {
|
| 1444 | 1442 |
public: |
| ... | ... |
@@ -1996,25 +1994,26 @@ |
| 1996 | 1994 |
} else {
|
| 1997 | 1995 |
augmentOnEdge(e); |
| 1998 | 1996 |
unmatched -= 2; |
| 1999 | 1997 |
} |
| 2000 | 1998 |
} break; |
| 2001 | 1999 |
} |
| 2002 | 2000 |
} |
| 2003 | 2001 |
return true; |
| 2004 | 2002 |
} |
| 2005 | 2003 |
|
| 2006 | 2004 |
/// \brief Run the algorithm. |
| 2007 | 2005 |
/// |
| 2008 |
/// This method runs the \c % |
|
| 2006 |
/// This method runs the \c %MaxWeightedPerfectFractionalMatching |
|
| 2007 |
/// algorithm. |
|
| 2009 | 2008 |
/// |
| 2010 | 2009 |
/// \note mwfm.run() is just a shortcut of the following code. |
| 2011 | 2010 |
/// \code |
| 2012 | 2011 |
/// mwpfm.init(); |
| 2013 | 2012 |
/// mwpfm.start(); |
| 2014 | 2013 |
/// \endcode |
| 2015 | 2014 |
bool run() {
|
| 2016 | 2015 |
init(); |
| 2017 | 2016 |
return start(); |
| 2018 | 2017 |
} |
| 2019 | 2018 |
|
| 2020 | 2019 |
/// @} |
0 comments (0 inline)