|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Helper class to verify that an optimal solution has been found. More...
#include <blossom_weighted_mwmatching.H>
Public Member Functions | |
| MatchingVerifier (const MatchingContext< WeightType > &ctx) | |
| bool | verify () |
| Verify that the optimum solution has been found. | |
Private Types | |
| using | EdgeT = Edge< WeightType > |
| using | BlossomT = Blossom< WeightType > |
| using | NonTrivialBlossomT = NonTrivialBlossom< WeightType > |
Private Member Functions | |
| std::size_t | edge_index (const EdgeT *edge) |
| Convert edge pointer to its index in the array "edges". | |
| bool | verify_vertex_mate () |
| Check that the array "vertex_mate" is consistent. | |
| bool | verify_vertex_duals () |
| Check that vertex dual variables are non-negative, and all unmatched vertices have zero dual. | |
| bool | verify_blossom_duals () |
| Check that blossom dual variables are non-negative. | |
| bool | check_blossom (const NonTrivialBlossomT *blossom) |
| Helper function for verifying the solution. | |
| bool | verify_blossoms_and_calc_edge_duals () |
| Check that all blossoms are full. | |
| bool | verify_edge_slack () |
| Check that all edges have non-negative slack, and check that all matched edges have zero slack. | |
Static Private Member Functions | |
| static bool | checked_add (WeightType &result, WeightType a, WeightType b) |
Private Attributes | |
| const MatchingContext< WeightType > & | ctx |
| Reference to the MatchingContext instance. | |
| const Problem_Data< WeightType > & | graph |
| Reference to the input graph. | |
| Array< WeightType > | edge_duals |
| For each edge, the sum of duals of its incident vertices and duals of all blossoms that contain the edge. | |
Helper class to verify that an optimal solution has been found.
Definition at line 1768 of file blossom_weighted_mwmatching.H.
|
private |
Definition at line 1799 of file blossom_weighted_mwmatching.H.
|
private |
Definition at line 1798 of file blossom_weighted_mwmatching.H.
|
private |
Definition at line 1800 of file blossom_weighted_mwmatching.H.
|
inline |
Definition at line 1771 of file blossom_weighted_mwmatching.H.
References Aleph::Array< T >::append(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::ctx, Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::edge_duals, and Aleph::Array< T >::reserve().
|
inlineprivate |
Helper function for verifying the solution.
Descend down the blossom tree to find edges that are contained in blossoms.
On the way down, keep track of the sum of dual variables of containing blossoms. Add blossom duals to edges that are contained inside blossoms.
On the way up, keep track of the total number of matched edges in subblossoms. Check that all blossoms with non-zero dual variables are "full".
Definition at line 1885 of file blossom_weighted_mwmatching.H.
References Aleph::Array< T >::append(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::checked_add(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::ctx, Aleph::divide_and_conquer_partition_dp(), Aleph::blossom_weighted_detail::mwmatching::impl::NonTrivialBlossom< WeightType >::dual_var, Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::edge_duals, Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::edge_index(), Aleph::blossom_weighted_detail::mwmatching::impl::for_vertices_in_blossom(), Aleph::DynListStack< T >::get(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::graph, Aleph::DynListStack< T >::is_empty(), Aleph::DynListStack< T >::put(), Aleph::Array< T >::reserve(), Aleph::DynListStack< T >::size(), Aleph::blossom_weighted_detail::mwmatching::impl::NonTrivialBlossom< WeightType >::subblossoms, Aleph::DynListStack< T >::top(), Aleph::blossom_weighted_detail::mwmatching::Edge< WeightType >::vt, and y.
Referenced by Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify_blossoms_and_calc_edge_duals().
|
inlinestaticprivate |
Definition at line 1802 of file blossom_weighted_mwmatching.H.
Referenced by Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::check_blossom(), and Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify_blossoms_and_calc_edge_duals().
|
inlineprivate |
Convert edge pointer to its index in the array "edges".
Definition at line 1811 of file blossom_weighted_mwmatching.H.
References Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::graph.
Referenced by Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::check_blossom(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify_blossoms_and_calc_edge_duals(), and Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify_edge_slack().
|
inline |
Verify that the optimum solution has been found.
This function takes time O(n**2).
Definition at line 1788 of file blossom_weighted_mwmatching.H.
References Aleph::and, Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify_blossom_duals(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify_blossoms_and_calc_edge_duals(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify_edge_slack(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify_vertex_duals(), and Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify_vertex_mate().
|
inlineprivate |
Check that blossom dual variables are non-negative.
Definition at line 1859 of file blossom_weighted_mwmatching.H.
References Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::ctx.
Referenced by Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify().
|
inlineprivate |
Check that all blossoms are full.
Also calculate the sum of dual variables for every edge.
Definition at line 2044 of file blossom_weighted_mwmatching.H.
References Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::check_blossom(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::checked_add(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::ctx, Aleph::divide_and_conquer_partition_dp(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::edge_duals, Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::edge_index(), and Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::graph.
Referenced by Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify().
|
inlineprivate |
Check that all edges have non-negative slack, and check that all matched edges have zero slack.
Definition at line 2071 of file blossom_weighted_mwmatching.H.
References Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::ctx, Aleph::divide_and_conquer_partition_dp(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::edge_duals, Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::edge_index(), and Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::graph.
Referenced by Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify().
|
inlineprivate |
Check that vertex dual variables are non-negative, and all unmatched vertices have zero dual.
Definition at line 1846 of file blossom_weighted_mwmatching.H.
References Aleph::and, Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::ctx, Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::graph, and Aleph::blossom_weighted_detail::mwmatching::impl::NO_VERTEX.
Referenced by Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify().
|
inlineprivate |
Check that the array "vertex_mate" is consistent.
Definition at line 1817 of file blossom_weighted_mwmatching.H.
References Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::ctx, Aleph::divide_and_conquer_partition_dp(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::graph, Aleph::blossom_weighted_detail::mwmatching::impl::NO_VERTEX, and y.
Referenced by Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify().
|
private |
Reference to the MatchingContext instance.
Definition at line 2091 of file blossom_weighted_mwmatching.H.
Referenced by Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::MatchingVerifier(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::check_blossom(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify_blossom_duals(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify_blossoms_and_calc_edge_duals(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify_edge_slack(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify_vertex_duals(), and Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify_vertex_mate().
|
private |
For each edge, the sum of duals of its incident vertices and duals of all blossoms that contain the edge.
Definition at line 2100 of file blossom_weighted_mwmatching.H.
Referenced by Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::MatchingVerifier(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::check_blossom(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify_blossoms_and_calc_edge_duals(), and Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify_edge_slack().
|
private |
Reference to the input graph.
Definition at line 2094 of file blossom_weighted_mwmatching.H.
Referenced by Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::check_blossom(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::edge_index(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify_blossoms_and_calc_edge_duals(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify_edge_slack(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify_vertex_duals(), and Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::verify_vertex_mate().