98 for (
size_t i = 0; i < s.num_nodes; ++i)
101 for (
const auto & [u, v, cost] : s.edges)
125 for (
auto it =
matching.get_it(); it.has_curr(); it.next_ne())
127 auto * arc = it.get_curr();
128 size_t u =
static_cast<size_t>(g.
get_src_node(arc)->get_info());
129 size_t v =
static_cast<size_t>(g.
get_tgt_node(arc)->get_info());
136 for (
auto it =
sorted_pairs.get_it(); it.has_curr(); it.next_ne())
137 pairs.
append(it.get_curr());
159 for (
size_t i = 0; i < pairs.
size(); ++i)
161 const auto & p = pairs(i);
163 if (i + 1 < pairs.
size())
220 cout <<
" " << backend_name
221 <<
" -> card " << result.cardinality
222 <<
", cost " << result.total_cost
227 cerr <<
" Warning: objective mismatch across backends\n";
243 cout <<
'\n' << s.title <<
'\n';
244 cout << string(s.title.size(),
'-') <<
'\n';
249 ?
"\nMode: maximum-cardinality then minimum-cost\n"
250 :
"\nMode: pure minimum-cost\n");
285 cout <<
" " << backend_name <<
" -> feasible "
286 << (result.feasible ?
"yes" :
"no");
290 cout <<
", card " << result.cardinality
291 <<
", cost " << result.total_cost
308 cout <<
'\n' << s.title <<
" (perfect matching)\n";
309 cout << string(s.title.size() + 19,
'-') <<
'\n';
323 const Scenario scenario{
324 .title =
"General min-cost matching (objective-mode demo)",
341 .title =
"Perfect min-cost matching demo (feasible)",
352 .title =
"Perfect min-cost matching demo (infeasible)",
361 cout <<
"Dedicated API: blossom_minimum_cost_matching()\n";
362 cout <<
"Dedicated API: blossom_minimum_cost_perfect_matching()\n";
363 cout <<
"All costs are edge costs in a non-bipartite graph.\n";
Minimum-cost matching in general undirected graphs.
Default distance accessor for arc weights.
size_t size() const noexcept
Return the current dimension of array.
T & append()
Allocate a new entry to the end of array.
bool is_empty() const noexcept
Return true if the array is empty.
Dynamic doubly linked list with O(1) size and bidirectional access.
Dynamic set backed by balanced binary search trees with automatic memory management.
Arc for graphs implemented with simple adjacency lists.
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
Node * get_src_node(Arc *arc) const noexcept
Return the source node of arc (only for directed graphs)
Node * get_tgt_node(Arc *arc) const noexcept
Return the target node of arc (only for directed graphs)
DynArray< Graph::Node * > nodes
Main namespace for Aleph-w library functions.
T & swap(T &t1, T &t2)
Generic swap using object's swap method.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
std::pair< First, Second > pair
Alias to std::pair kept for backwards compatibility.
std::string to_string(const time_t t, const std::string &format)
Format a time_t value into a string using format.
Default filter for filtered iterators on arcs.
Arc of graph implemented with double-linked adjacency lists.
Array-based graph implementation.
Lazy and scalable dynamic array implementation.
Dynamic set implementations based on balanced binary search trees.
Generic graph and digraph implementations.
Simple graph implementation with adjacency lists.