Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
hungarian_example.cc File Reference
#include <iostream>
#include <Hungarian.H>
#include <tpl_dynMat.H>
Include dependency graph for hungarian_example.cc:

Go to the source code of this file.

Functions

void example_basic_assignment ()
 Demonstrates a 4x4 workers-to-tasks assignment using Hungarian_Assignment.
 
void example_maximization ()
 Demonstrates maximizing total profit for a 3x3 profit matrix and prints the results.
 
void example_rectangular ()
 Demonstrates rectangular assignment (3 workers, 5 tasks) using Hungarian_Assignment.
 
int main ()
 Runs the three Hungarian algorithm example demonstrations.
 

Function Documentation

◆ example_basic_assignment()

void example_basic_assignment ( )

Demonstrates a 4x4 workers-to-tasks assignment using Hungarian_Assignment.

Prints a labeled 4x4 cost matrix, constructs a Hungarian_Assignment<int> with those costs, outputs the optimal total cost and the worker->task assignments, and then prints the individual per-assignment costs using a local constexpr matrix.

Definition at line 45 of file hungarian_example.cc.

References Aleph::divide_and_conquer_partition_dp(), Aleph::Hungarian_Assignment< Cost_Type >::get_total_cost(), and r.

Referenced by main().

◆ example_maximization()

void example_maximization ( )

Demonstrates maximizing total profit for a 3x3 profit matrix and prints the results.

Constructs a 3x3 DynMatrix of integer profits, computes a maximum-weight assignment using hungarian_max_assignment, and writes the profit matrix, the maximum total profit, and each worker->job assignment with its profit to standard output.

Definition at line 91 of file hungarian_example.cc.

References Aleph::divide_and_conquer_partition_dp(), Aleph::hungarian_max_assignment(), and r.

Referenced by main().

◆ example_rectangular()

void example_rectangular ( )

Demonstrates rectangular assignment (3 workers, 5 tasks) using Hungarian_Assignment.

Prints a labeled 3x5 cost matrix to stdout, constructs a Hungarian_Assignment<int> with the hard-coded costs, then prints the optimal total cost and the worker→task assignments (two tasks remain unassigned).

Definition at line 126 of file hungarian_example.cc.

References Aleph::divide_and_conquer_partition_dp(), Aleph::Hungarian_Assignment< Cost_Type >::get_total_cost(), and r.

Referenced by main().

◆ main()

int main ( )

Runs the three Hungarian algorithm example demonstrations.

Calls example_basic_assignment(), example_maximization(), and example_rectangular() to print example matrices, optimal assignments, and total costs.

Returns
int 0 on success.

Definition at line 159 of file hungarian_example.cc.

References example_basic_assignment(), example_maximization(), and example_rectangular().