# Subset of a bipartite graph with maximal number of minimal unmatched vertices

Given a bipartite graph $G = (U \sqcup V, E)$ with sets of vertices $U$ and $V$ and edge set $E \subseteq U \times V$, a matching $M$ is a subset of $E$ whose edges have no common vertices: for all $(u, v)$ and $(u', v') \in M$, $u = u'$ or $v = v'$ implies $(u, v) = (u', v')$. A maximum matching is a matching containing the maximum number of edges. It is immediate that a maximum matching is a matching achieving the minimal number of unmatched vertices, where I say that $u \in U$ is unmatched in $M$ if there is no $(u', v') \in M$ such that $u = u'$, and likewise for $v \in V$. Hence, the minimal number of unmatched vertices in $G$ over all possible matchings of $G$, that I write $f(G)$, can be computed by finding a maximum matching, which can be done in polynomial time with, e.g., the Hopcroft-Karp algorithm.

I now consider the following problem: from a bipartite graph $G = (U \sqcup V, E)$, what is the maximum, over all subsets $U'$ of $U$, of $f(G_{|U'})$? By $G_{|U'}$ I mean the bipartite graph which is the restriction of $G$ to $U'$, namely $G_{|U'} = (U' \sqcup V, \{(u, v) \in E \mid u \in U'\})$.

Is this problem NP-hard, or can it be solved in PTIME? On the one hand it seems related to set cover or exact cover which are NP-hard, but on the other hand the subproblem of maximum matching is PTIME and maybe there is a clever way to identify what is the worst subset.

To motivate this problem, here is a rephrasing in terms of assignments of agents to tasks. $U$ is a set of tasks, $V$ a set of agents, and $E$ indicates which agents can perform which tasks. A matching is a way of assigning tasks to agents such that each agent does at most one task and each task is done by at most one agent. The cost measure is the number of unmatched vertices, namely the number of undone tasks plus the number of unoccupied agents. I want to know what is my worst possible cost in this sense, over all subsets of the tasks (think of $U$ as a set of possible tasks from which an arbitrary subset will be requested, and $V$ as a fixed set of agents that I cannot adjust but which I can allocate freely once a subset has been requested).

To see why this problem is not trivial, observe that choosing the empty subset $\emptyset \subseteq U$ yields a cost of $|V|$ (the cost of leaving all agents unoccupied), the complete subset $U \subseteq U$ yields a certain cost and may be the worst if e.g. $|U|$ is much larger than $|V|$, but in general my best solution may be to choose a subset of $U$ which retains the tasks than can be done by only few agents (so that many of them will have to remain undone as each of those agents can do only one task) but would not retain the tasks that can be done by otherwise unoccupied agents (so that those agents remain unoccupied and contribute to the cost).

If this problem is in PTIME, I am also interested to know if the following weighted version is also PTIME: each vertex and each edge has a weight, the cost of a matching is the sum of the weights of the unmatched vertices plus the sum of the weights of the retained edges, and I want again to find the subset of $U$ with the worst minimal cost in this sense. In the vocabulary of the assignment problem, this means that each task and each agent has an individual cost of remaining undone or unoccupied, and assigning a task to an agent is not free anymore but carries a certain cost indicated on the edge.

• The title says "least number of unmatched edges" but the question says "minimal number of unmatched vertices". I assume you mean the latter, since deleting all of $U$ deletes all edges so is a trivial solution to the former. Dec 18, 2013 at 20:19
• Ah, you're right, I fixed the title, now it should be correct. Thanks a lot for pointing this out!
– a3nm
Dec 19, 2013 at 1:05

The problem is in $P$ by reducing the problem to submodular minimization.

Let $v(A)$ be defined as the size of the maximum matching in $G_{|A}$. $v$ is submodular. One way to see this is convert the problem to a max flow problem, and use the fact that the set function $c(U)=$ max flow from $U$ to $t$ defined over $V\setminus \{t\}$ is submodular.

I will use $f(A)$ to mean the $f(G_{|A})$ in your notation.

$f(A) = |A| + |V| - 2v(A)$. $|V|$ is a constant, so we can maximize over $f(A)-|V| = |A| - 2v(A)$, which is the same as minimize $g(A) = 2v(A)-|A|$. $g$ is a submodular function(difference of submodular and modular function), and you can apply any polynomial time submodular function minimization algorithm.

This can be extended to weighted case if weighted analogue of $v(A)$ is submodular.

• Thanks very much! I didn't know about submodular functions, but your idea looks good to me. When reading I assumed that $A$ ranges over subsets of $U$. I checked manually that $v$ is submodular by saying that if $X \subseteq Y \subseteq U$ and $x \in U \backslash Y$ then, if adding $x$ to $Y$ can increase the size of the maximum matching (i.e., $x$ can be matched, i.e., a maximum matching with $Y$ leaves free a neighbor of $x$) then the same holds with $X$ as $X \subseteq Y$. I then checked that $g$ is submodular using $g(S) + g(T) \geq g(S \cup T) + g(S \cap T)$ (it simplifies). Thanks again!
– a3nm
Jan 20, 2016 at 1:02
{"ft_lang_label":"__label__en","ft_lang_prob":0.93257886,"math_prob":0.997655,"size":3412,"snap":"2023-40-2023-50","text_gpt3_token_len":864,"char_repetition_ratio":0.12940142,"word_repetition_ratio":0.027734976,"special_character_ratio":0.25937867,"punctuation_ratio":0.08635098,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9999213,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-11-28T11:32:14Z\",\"WARC-Record-ID\":\"<urn:uuid:1abf1a71-7942-466e-9015-59c21f86dd3a>\",\"Content-Length\":\"167588\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:04b450a4-0330-4b7c-be49-2dd255ec6dcb>\",\"WARC-Concurrent-To\":\"<urn:uuid:27b705e9-ec66-4e7d-810b-7795c947164d>\",\"WARC-IP-Address\":\"172.64.144.30\",\"WARC-Target-URI\":\"https://cstheory.stackexchange.com/questions/20245/subset-of-a-bipartite-graph-with-maximal-number-of-minimal-unmatched-vertices\",\"WARC-Payload-Digest\":\"sha1:KGGPS3VLU67EDJTVJAYEXOCDNYXIJX3M\",\"WARC-Block-Digest\":\"sha1:4GLNIB673YPWGCK64G7TBIXINBTMTKTD\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679099281.67_warc_CC-MAIN-20231128083443-20231128113443-00045.warc.gz\"}"}