Fix bug in C++ maximum cardinality adjustment
This commit is contained in:
parent
a4da35d3aa
commit
d08e3e1c58
|
@ -482,12 +482,10 @@ struct MatchingContext
|
||||||
/** Count the number of vertices in the graph. */
|
/** Count the number of vertices in the graph. */
|
||||||
static VertexId count_num_vertex(const std::vector<EdgeT>& edges)
|
static VertexId count_num_vertex(const std::vector<EdgeT>& edges)
|
||||||
{
|
{
|
||||||
const VertexId max_num_vertex = std::numeric_limits<VertexId>::max();
|
|
||||||
|
|
||||||
VertexId num_vertex = 0;
|
VertexId num_vertex = 0;
|
||||||
for (const Edge<WeightType>& edge : edges) {
|
for (const Edge<WeightType>& edge : edges) {
|
||||||
VertexId m = std::max(edge.vt.first, edge.vt.second);
|
VertexId m = std::max(edge.vt.first, edge.vt.second);
|
||||||
assert(m < max_num_vertex);
|
assert(m < std::numeric_limits<VertexId>::max());
|
||||||
num_vertex = std::max(num_vertex, m + 1);
|
num_vertex = std::max(num_vertex, m + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1840,7 +1838,7 @@ struct MatchingContext
|
||||||
// Count the number of vertices inside this blossom.
|
// Count the number of vertices inside this blossom.
|
||||||
VertexId blossom_num_vertex = 0;
|
VertexId blossom_num_vertex = 0;
|
||||||
for_vertices_in_blossom(blossom,
|
for_vertices_in_blossom(blossom,
|
||||||
[&blossom_num_vertex](VertexId x) {
|
[&blossom_num_vertex](VertexId) {
|
||||||
++blossom_num_vertex;
|
++blossom_num_vertex;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2070,10 +2068,8 @@ template <typename WeightType>
|
||||||
std::vector<Edge<WeightType>> adjust_weights_for_maximum_cardinality_matching(
|
std::vector<Edge<WeightType>> adjust_weights_for_maximum_cardinality_matching(
|
||||||
const std::vector<Edge<WeightType>>& edges_in)
|
const std::vector<Edge<WeightType>>& edges_in)
|
||||||
{
|
{
|
||||||
const WeightType min_safe_weight =
|
const WeightType min_safe_weight = std::numeric_limits<WeightType>::min() / 4;
|
||||||
std::numeric_limits<WeightType>::min() / 4;
|
const WeightType max_safe_weight = std::numeric_limits<WeightType>::max() / 4;
|
||||||
const WeightType max_safe_weight =
|
|
||||||
std::numeric_limits<WeightType>::max() / 4;
|
|
||||||
|
|
||||||
// Copy edges.
|
// Copy edges.
|
||||||
std::vector<Edge<WeightType>> edges(edges_in);
|
std::vector<Edge<WeightType>> edges(edges_in);
|
||||||
|
@ -2086,7 +2082,7 @@ std::vector<Edge<WeightType>> adjust_weights_for_maximum_cardinality_matching(
|
||||||
// Count number of vertices.
|
// Count number of vertices.
|
||||||
// Determine minimum and maximum edge weight.
|
// Determine minimum and maximum edge weight.
|
||||||
VertexId num_vertex = 0;
|
VertexId num_vertex = 0;
|
||||||
WeightType min_weight = edges.first().weight;
|
WeightType min_weight = edges.front().weight;
|
||||||
WeightType max_weight = min_weight;
|
WeightType max_weight = min_weight;
|
||||||
|
|
||||||
const VertexId max_num_vertex = std::numeric_limits<VertexId>::max();
|
const VertexId max_num_vertex = std::numeric_limits<VertexId>::max();
|
||||||
|
|
Loading…
Reference in New Issue