function matches = link_munkres(cost, non_assignment_cost)
	% use munkres algorithm to make an assignment iA -> iB
	% which minimises
	%	total cost = sum_n cost(iA(n), iB(n))
	%
	% cost is a sparse matrix represnting potential assignments A->B
	% zero elements represent invalid assignments
	%
	% uses assignmunkres to do the hard work

	%% solve simple assignment problem
	% in cases where there are no other possible assignments A->B
	% we can 
	onerow = sum(cost~=0, 1) == 1;
	onecol = sum(cost~=0, 2) == 1;

	simple_cost = cost;
	simple_cost(:, ~onerow) = 0;
	simple_cost(~onecol, :) = 0;



	% https://uk.mathworks.com/help/fusion/ref/assignmunkres.html#mw_dfbf9157-335c-4bbf-a4dc-afd9f935bd3e_sep_mw_9561721d-614d-4d38-82c3-b633f3c66446