1 Introduction

The Stable Marriage Problem is one of the most actively studied problems in theoretical computer science and economics [13, 23]. It has many real-world applications including assignments of medical residents [22] and high-school students [1, 2]. In the original bipartite setting called Marriage Problem (mp), a set of n/2 men and a set of n/2 women are given. Each person has a preference list that ranks all people of opposite gender in strict order of preference. A man m and a woman w are called a blocking pair for a matching M if they are not matched with each other in M but prefer each other to their own partners in M. A matching is called stable if it does not admit any blocking pair. Gale and Shapley [9] proved that a stable matching always exists in any instance and developed an O(n2) algorithm to find one. Their algorithm can be adapted to a setting where each person’s preference list may not contain all people of opposite gender. It runs in O(m) time in this setting, where m is the total length of people’s preference lists [13].

The Stable Roommates Problem is a generalization of the original Stable Marriage Problem to a non-bipartite setting called Roommates Problem (rp), where each person can be matched with anyone regardless of gender. Unlike in mp, a stable matching in rp does not always exist. Irving [16] developed an O(n2) algorithm to find a stable matching in a given rp instance, or report that none exists.

1.1 Popular Matchings

Apart from stability, another well-studied property of a preferable matching is popularity. For a pair of matchings X and Y, let ϕ(X,Y ) denote the number of people who prefer a person they get matched by X to a person they get matched by Y. A matching M is called popular if \(\phi (M,M^{\prime }) \geq \phi (M^{\prime },M)\) for any other matching \(M^{\prime }\). The concept of popularity of a matching was first introduced by Gardenfors [10] in the context of the original Stable Marriage Problem. He also proved that in an mp instance where each person’s preference list is strict (containing no tie), every stable matching must be popular (but not vice-versa), hence a popular matching always exists.

The problem of determining whether a popular matching exists in a given instance, however, becomes more computationally challenged in other settings. Biró et al. [5] proved that when ties among people in the preference lists are allowed, the problem of determining whether a popular matching exists in a given mp or rp instance is NP-hard. Very recently, Faenza et al. [8] and Gupta et al. [12] independently proved that this problem is still NP-hard for rp even when people’s preference lists are strict. Cseh and Kavitha [6] showed that in a complete graph rp instance where each person’s preference list is strict and contains all other people, the problem of determining whether a popular matching exists is solvable in polynomial time for an odd n but is NP-hard for an even n.

Problems related to popular matchings were also extensively studied in the setting of one-sided preference lists (matching each person with a unique item, where each person has a list that ranks items but each item does not have a list that ranks people) called House Allocation Problem (hap). Abraham et al. [3] developed an algorithm to find a popular matching in a given hap instance, or report that none exists. The algorithm runs in O(m + n) time when people’s preference lists are strict and in \(O(m\sqrt {n})\) time when ties are allowed, where m is the total length of people’s preference lists and n is the total number of people and items. Mestre [21] later generalized their algorithm to a weighted setting where people are given different voting weights, while Manlove and Sng [19] generalized it to a setting where each item is allowed to be matched with more than one person called Capacitated House Allocation Problem (chap). Mahdian [18] studied the randomized version of this problem where people’s preference lists are strict, complete (containing all items), and randomly generated. He showed that a popular matching exists with high probability in a random hap instance if the ratio of the number of items to the number of people is greater than a specific constant. Ruangwises and Itoh [24] later generalized Mahdian’s study to the case where preference lists are strict but not complete, and found a similar behavior of the probability of existence of a popular matching. Abraham and Kavitha [4] proved that in any instance with at least one popular matching, one can achieve a popular matching by conducting at most two majority votes to force a change in assignments, starting at any matching. Kavitha et al. [17] introduced the concept of a mixed matching, which is a probability distribution over a set of matchings, and proved that a mixed matching that is “popular” always exists.

1.2 Unpopularity Measures

While a popular matching may not exist in some instances, several measures of badness of a matching that is not popular have been introduced. In the one-sided preference lists setting, McCutchen [20] introduced two such measures: the unpopularity factor and the unpopularity margin. The unpopularity factor u(M) of a matching M is the maximum ratio \(\phi (M^{\prime },M) / \phi (M,M^{\prime })\) among all other possible matchings \(M^{\prime }\), while the unpopularity margin g(M) is the maximum difference \(\phi (M^{\prime },M) - \phi (M,M^{\prime })\) among all other possible matchings \(M^{\prime }\). Note that the two measures are not equivalent as \(\phi (M^{\prime },M)\) and \(\phi (M,M^{\prime })\) may not add up to the total number of people since some people may like M and \(M^{\prime }\) equally, thus it is possible for a matching to have higher unpopularity factor but lower unpopularity margin than another matching. See Example 1.

McCutchen [20] developed an algorithm to compute u(M) and g(M) of a given matching M of an hap instance in \(O(m\sqrt {n_{2}})\) and \(O((g+1)m\sqrt {n})\) time, respectively, where n2 is the number of items and g = g(M) is the unpopularity margin of M. He also proved that the problem of finding a matching that minimizes either measure is NP-hard. Huang et al. [15] later developed an algorithm to find a matching with bounded values of these measures in hap instances with certain properties.

The notions of unpopularity factor and unpopularity margin also apply to the setting of two-sided preference lists (matching people with people). Biró et al. [5] developed an algorithm to determine whether a given matching M is popular in \(O(m\sqrt {n \alpha (n,m)}\log ^{3/2} n)\) time for rp, where α is the inverse Ackermann function (later improved to \(O(m\sqrt {n}\log n)\) time when running with the recent fastest algorithm to find a maximum weight perfect matching [7]), and in \(O(m\sqrt {n})\) time for mp. Their algorithm also simultaneously computes the unpopularity margin of M during the run. Huang and Kavitha [14] proved that an rp instance with strict preference lists always has a matching with unpopularity factor \(O(\log n)\), and it is NP-hard to find a matching with the lowest unpopularity factor, or even the one with less than 4/3 times of the optimum.

Example 1

Consider the following rp instance. A set in a preference list means all people in that set are ranked equally, e.g. a2 prefers a1 and a4 equally as his first choices over a3.

figure a

In this example, ϕ(M0,M1) = 1, ϕ(M1,M0) = 0, ϕ(M0,M2) = 3, ϕ(M2,M0) = 1, ϕ(M1,M2) = 3, and ϕ(M2,M1) = 1. Therefore, M0 is popular, while \(u(M_1) = \infty \), g(M1) = 1 − 0 = 1, u(M2) = 3/1 = 3, and g(M2) = 3 − 1 = 2. Observe that M1 has higher unpopularity factor but lower unpopularity margin than M2.

1.3 Our Contribution

The algorithm of Biró et al. [5] determines whether a given matching M is popular and also simultaneously computes the unpopularity margin of M, hence we currently have an algorithm to compute an unpopularity margin of a given matching in \(O(m\sqrt {n}\log n)\) time for rp and in \(O(m\sqrt {n})\) time for mp. However, there is currently no efficient algorithm to compute an unpopularity factor of a given matching in mp or rp.

In this paper, by employing an auxiliary graph similar to the one in [5], we develop an algorithm to compute the unpopularity factor of a given matching. The algorithm runs in \(O(m\sqrt {n}\log ^2 n)\) time for rp and in \(O(m\sqrt {n}\log n)\) time for mp. We also generalize the notion of unpopularity factor to the weighted setting where people are given different voting weights, and show that our algorithm can be slightly modified to support that setting with the same running time.

2 Preliminaries

Let I be an rp or mp instance consisting of a set A = {a1,...,an} of n people, with each person having a preference list that ranks a subset of A as his/her acceptable partners in order of preference. In rp there is no further restriction, while in mp people are classified into two genders, and each person’s preference list can contain only people of opposite gender. Throughout this paper, we consider a more general setting where ties among two or more people are allowed in the preference lists. Also, let m be the total length of people’s preference lists.

For a matching M and a person aA, let M(a) be the person matched with a in M (for convenience, let M(a) = null if a is unmatched in M). Also, let ra(b) be the rank of a person b in a’s preference list, with the most preferred item(s) having rank 1, the second most preferred item(s) having rank 2, and so on (for convenience, let \(r_a(null) = \infty \)).

For any pair of matchings X and Y, we define ϕ(X,Y ) to be the number of people who strictly prefer the person they get matched by X to the person they get matched by Y, i.e.

$$\phi(X,Y) = |\{a \in A|r_a(X(a)) < r_a(Y(a))\}|.$$

Also, let

$$ {\varDelta}(X,Y) = \left\{\begin{array}{ll} \phi(Y,X) / \phi(X,Y), &\ \text{if } \phi(X,Y) > 0; \\ 1, &\ \text{if } \phi(X,Y) = \phi(Y,X) = 0; \\ \infty, &\ \text{otherwise.} \end{array}\right. $$

Finally, define an unpopularity factor

$$u(M) = \max_{M' \in \mathbb{M}-\{M\}} {\varDelta}(M,M'),$$

where \(\mathbb {M}\) is the set of all matchings of a given instance I. Note that a matching M is popular if and only if u(M) ≤ 1.

3 Unweighted Setting

We first consider an unweighted setting where every person has equal voting weight.

3.1 rp Instances

Let I be an rp instance, M be a matching of I, and k be an arbitrary positive rational number. Beginning with a similar approach to [5], we construct an undirected graph H(M,k) with vertices AA, where A = {a1′,...,an′} is a set of “copies” of people in A. An edge {ai,aj} exists if and only if ai is in aj’s preference list and aj is in ai’s preference list; an edge {ai′,aj′} exists if and only if {ai,aj} exists; an edge {ai,aj′} exists if and only if i = j.

The major distinction of our algorithm is that we assign weights to edges of H(M,k) differently from [5]. For each pair of i and j with an edge {ai,aj}, define δi,j as follows.

$$ \delta_{i,j} = \left\{\begin{array}{ll} 1, &\ \text{if } a_i \ \text{ is unmatched in } M \ \text{ or } a_i \ \text{ prefers } a_j \ \text{ to } M(a_i); \\ -k, &\ \text{if } a_i \ \text{ prefers } M(a_i) \ \text{ to } a_j; \\ 0, &\ \text{if } \{a_i,a_j\} \in M \ \text{ or } a_i \ \text{ likes } a_j \ \text{ and } M(a_i) \ \text{ equally}. \end{array}\right. $$

For each pair of i and j, we set the weights of both {ai,aj} and {ai′,aj′} to be δi,j + δj,i. Finally, for each edge {ai,ai′}, we set its weight to be − 2k if ai is matched in M, and 0 otherwise. See Example 2.

Example 2

Consider the following matching M in an rp instance.

figure b

The values of all δi,j are shown in the top-right table, and the auxiliary graph H(M,2) is shown at the bottom.

The intuition of constructing this auxiliary graph is that we want to check whether u(M) > k, i.e. whether there exists another matching M with the number of people who prefer M to M more than k times the number of those who prefer M to M. Each matching M is represented by a perfect matching of H(M,k) consisting of the edges of M in A as well as their copies in A, with each unmatched person ai being matched with his own copy ai′. We want to add 1 for each person who prefers M to M and subtract k for each one who prefers M to M, and then check whether the sum is positive. This is the reason that we set δi,j to be − k if ai prefers M(ai) to aj, and the weight of {ai,ai′} to be − 2k if ai is unmatched in M.

The relation between u(M) and the graph H(M,k) is formally shown in the following lemma.

Lemma 1

u(M) > k if and only if H(M,k) contains a positive weight perfect matching.

Proof

For any matching M, define A1(M) to be a set of people in A that are matched in M, and A2(M) to be a set of people in A that are unmatched in M. Also, define

$$ \begin{array}{@{}rcl@{}} A^+_1(M') &=& \{a_i \in A_1(M')|a_i\ \text{ is unmatched in }M\ \text{ or }a_i\ \text{ prefers }M'(a_i)\ \text{ to }M(a_i)\}; \\ A^-_1(M') &=& \{a_i \in A_1(M')|a_i\ \text{ prefers }M(a_i)\ \text{ to }M'(a_i)\}; \\ A^-_2(M') &=& \{a_i \in A_2(M')|a_i\ \text{ is matched in }M\}. \end{array} $$

We have ϕ(M,M) = |A1+(M)| and ϕ(M,M) = |A1−(M)| + |A2−(M)|.

Suppose that u(M) > k. From the definition of u(M), there must be a matching M0 such that ϕ(M0,M) > kϕ(M,M0). In the graph H(M,k), consider a perfect matching

$$S_0 = M_0 \cup \{\{a'_i,a'_j\}|\{a_i,a_j\} \in M_0\} \cup \{\{a_i,a'_i\}|a_i\ \ \text{ is unmatched in }M_0\}$$

with weight W0. From the definition, we have

$$ \begin{array}{@{}rcl@{}} W_0 &=& 2\left( |A^+_1(M_0)|-k|A^-_1(M_0)|\right)-2k|A^-_2(M_0)| \\ &=& 2\left( |A^+_1(M_0)|-k\left( |A^-_1(M_0)|+|A^-_2(M_0)|\right)\right) \\ &=& 2(\phi(M_0,M) - k\phi(M,M_0)) \\ &>& 0, \end{array} $$

hence H(M,k) contains a positive weight perfect matching.

On the other hand, suppose there is a positive weight perfect matching S1 of H(M,k) with weight W1. See Example 3. Let M1 = {{ai,aj}∈ S1} and M2 = {{ai,aj}|{ai′,aj′}∈ S1}. Since S1 is a perfect matching of H(M,k), we have A2(M1) = A2(M2), and

$$ \begin{array}{@{}rcl@{}} 0 &<& W_1 \\ &=& \left( |A^+_1(M_1)|-k|A^-_1(M_1)|\right) + \left( |A^+_1(M_2)|-k|A^-_1(M_2)|\right) - 2k|A^-_2(M_1)| \\ &=& \left( |A^+_1(M_1)|-k|A^-_1(M_1)|\right) + \left( |A^+_1(M_2)|-k|A^-_1(M_2)|\right) - k|A^-_2(M_1)|-k|A^-_2(M_2)| \\ &=& (\phi(M_1,M) - k\phi(M,M_1)) + (\phi(M_2,M) - k\phi(M,M_2)). \end{array} $$

Therefore, we have either ϕ(M1,M) > kϕ(M,M1) or ϕ(M2,M) > kϕ(M,M2), which implies u(M) > k. □

Example 3

Consider the auxiliary graphs H(M,2) and H(M,3) constructed from a matching M in Example 2.

figure c

On the left, \(H_{(M,2)}\) has a positive weight perfect matching consisting of the bold-faced edges, but on the right, H(M,3) does not. This implies 2 < u(M) ≤ 3.

For a given value of k, the problem of determining whether u(M) > k is now transformed to detecting a positive weight perfect matching of H(M,k), which can be done by finding the maximum weight perfect matching of H(M,k).

Lemma 2

Given an rp instance I, a matching M of I, and a rational number k = x/y, where x ∈ [0,n − 1] and y ∈ [1,n] are integers, there is an algorithm to determine whether u(M) > k in \(O(m\sqrt {n}\log n)\) time.

Proof

From Lemma 1, the problem of determining whether u(M) > k is equivalent to determining whether H(M,k) has a positive weight perfect matching. Observe that H(M,k) has O(n) vertices and O(m) edges, and we can multiply the weights of all edges by y so that they are all integers with magnitude O(n). Using the recent algorithm of Duan et al. [7], we can find a maximum weight perfect matching in a graph with integer weight edges of magnitude poly(n) in \(O(m\sqrt {n}\log n)\) time, hence we can detect a positive weight perfect matching in H(M,k) in \(O(m\sqrt {n}\log n)\) time. □

As the possible values of u(M) are limited, we can perform a binary search for its value. This allows us to efficiently compute u(M). To the best of our knowledge, this is the first approach on popular matchings that employs the binary search technique.

Theorem 1

Given an rp instance I and a matching M of I, there is an algorithm to compute u(M) in \(O(m\sqrt {n}\log ^2 n)\) time.

Proof

Observe that if u(M) is not \(\infty \), it must be in the form of x/y, where x ∈ [0,n − 1] and y ∈ [1,n] are integers, meaning that there are at most n2 possible values of u(M). By performing a binary search on the value of k = x/y (if u(M) > n − 1, then \(u(M) = \infty \)), we run the algorithm in Lemma 2 to determine whether u(M) > k for \(O(\log n^2) = O(\log n)\) times to find the exact value of u(M), hence the total running time is \(O(m\sqrt {n}\log ^2 n)\). □

3.2 mp Instances

The running time of the algorithm in Theorem 1 is for a general rp instance. However, in an mp instance we can improve it using the following approach. For any matching M in an mp instance, we define a matching

$$S = M \cup \{\{a'_i,a'_j\}|\{a_i,a_j\} \in M\} \cup \{\{a_i,a'_i\}|a_i\ \ \text{ is unmatched in }M\}$$

in the graph H(M,k). Since S is a perfect matching, for any perfect matching S of H(M,k), every edge of S that is not in S must be a part of some cycle in which the edges alternate between S and S. Moreover, from the definition of δi,j, every edge of S has zero weight. Therefore, H(M,k) contains a positive weight perfect matching if and only if it contains a positive weight alternating cycle relative to S. Hence, the problem becomes equivalent to detecting a positive weight alternating cycle (relative to S) in H(M,k). Note that this property holds for every rp instance, not limited to only mp.

However, the special property of mp is that A is bipartite. Let AM and AW be the two parts of A with no edge between vertices in the same part (which correspond to the sets of men and women, respectively). Also, let AM′ = {ai′|aiAM} and AW′ = {ai′|aiAW}. Observe that we can divide the vertices of H(M,k) into two parts H1 = AMAW′ and H2 = AWAM′ with no edge between vertices in the same part, so H(M,k) is also bipartite. In H(M,k), we orient the edges of S toward H2 and all other edges toward H1, hence the problem of detecting a positive weight alternating cycle becomes equivalent to detecting a positive weight directed cycle (see Example 4), which can be done in \(O(m\sqrt {n})\) time using the shortest path algorithm of Goldberg [11]. Therefore, by performing a binary search on the value of u(M) similar to in rp, the total running time for mp is \(O(m\sqrt {n}\log n)\).

Example 4

Consider the following matching M in an mp instance with men a1 and a3, and women a2 and a4.

figure d

On the left, \(H_{(M',2)}\) has a positive weight perfect matching consisting of the bold-faced edges, while S consists of the dotted edges.

On the right, since \(H_{(M',2)}\) is a bipartite graph with parts H1 = {a1,a3,a2′,a4′} (white vertices) and H2 = {a2,a4,a1′,a3′} (gray vertices), we orient the edges of S (dotted arrows) toward H2, and the rest toward H1. This directed graph has a positive weight directed cycle consisting of the bold-faced arrows. Both figures imply u(M) > 2.

In a way similar to rp, we have the following lemma and theorem for mp.

Lemma 3

Given an mp instance I, a matching M of I, and a number k = x/y, where x ∈ [0,n − 1] and y ∈ [1,n] are integers, there is an algorithm to determine whether u(M) > k in \(O(m\sqrt {n})\) time.

Theorem 2

Given an mp instance I and a matching M of I, there is an algorithm to compute u(M) in \(O(m\sqrt {n}\log n)\) time.

4 Weighted Setting

The previous section shows the algorithm to compute an unpopularity factor of a given matching in an unweighted rp or mp instance where every person has equal voting weight. However, in many real-world situations, people may have different voting weights based on position, seniority, etc. Our algorithm can also be slightly modified to support a weighted instance with integer weights bounded by N = poly(n) with the same running time in both rp and mp.

In the weighted setting, each person aiA has a weight w(ai). We analogously define ϕ(M,M) to be the sum of weights of people who strictly prefer a matching M to a matching M, i.e.

$$\phi(M,M') = \sum\limits_{a \in A_{(M,M')}} w(a),$$

where \({A_{(M,M')} = \{a \in A|r_a(M(a)) < r_a(M'(a))\}}\). We also define Δ(M,M) and u(M) the same way as in the unweighted setting. For each aiA, we assume that w(ai) is a non-negative integer not exceeding N = poly(n). Note that an unweighted instance can be viewed as a special case of a weighted instance where w(ai) = 1 for all aiA.

To support the weighted setting, we construct an auxiliary graph H(M,k) with the same set of vertices and edges as in the unweighted setting, but with slightly different weights of the edges. For each pair of i and j with an edge {ai,aj}, define

$$ \delta_{i,j} = \left\{\begin{array}{ll} w(a_i), &\ \text{if } a_i \ \text{ is unmatched in } M \ \text{ or } a_i \ \text{ prefers } a_j \ \text{ to } M(a_i); \\ -kw(a_i), &\ \text{if } a_i \ \text{ prefers } M(a_i) \ \text{ to } a_j; \\ 0, &\ \text{if } \{a_i,a_j\} \in M \ \text{ or } a_i \ \text{ likes } a_j \ \text{ and } M(a_i) \ \text{ equally}. \end{array}\right. $$

For each pair of i and j, the weights of {ai,aj} and {ai′,aj′} is δi,j + δj,i. Finally, for each edge {ai,ai′}, we set its weight to be − 2kw(ai) if ai is matched in M, and 0 otherwise.

The auxiliary graph H(M,k) still has the same relation with u(M), as shown in the following lemma.

Lemma 4

In the weighted rp instance, u(M) > k if and only if H(M,k) contains a positive weight perfect matching.

Proof

The proof of this lemma is very similar to that of Lemma 1. We define the sets A1(M), A2(M), A1+(M), A1−(M), and A2−(M) by the same way as in the proof of Lemma 1. However, from now on we will compute the sum of weights of each set’s elements instead of counting the number of its elements.

For any set B, define \(w(B) = {\sum }_{a \in B} w(a)\). We have ϕ(M,M) = w(A1+(M)) and ϕ(M,M) = w(A1−(M)) + w(A2−(M)).

Suppose that u(M) > k. There must exist a matching M0 such that ϕ(M0,M) > kϕ(M,M0). Similarly to the proof of Lemma 1, in the graph H(M,k) consider a perfect matching

$$S_0 = M_0 \cup \{\{a'_i,a'_j\}|\{a_i,a_j\} \in M_0\} \cup \{\{a_i,a'_i\}|a_i\ \ \text{ is unmatched in }M_0\}$$

with weight W0. From the definition, we have

$$ \begin{array}{@{}rcl@{}} W_0 &=& 2\left( w(A^+_1(M_0))-kw(A^-_1(M_0))\right)-2kw(A^-_2(M_0)) \\ &=& 2\left( w(A^+_1(M_0))-k\left( w(A^-_1(M_0))+w(A^-_2(M_0))\right)\right) \\ &=& 2(\phi(M_0,M) - k\phi(M,M_0)) \\ &>& 0, \end{array} $$

hence H(M,k) contains a positive weight perfect matching.

On the other hand, suppose there is a positive weight perfect matching S1 of H(M,k) with weight W1. Let M1 = {{ai,aj}∈ S1} and M2 = {{ai,aj}|{ai′,aj′}∈ S1}. Similarly to the proof of Lemma 1, we have A2(M1) = A2(M2), and

$$ \begin{array}{@{}rcl@{}} 0 \!\!&<& W_1\\ &=& \left( w(A^+_1(M_1))-kw(A^-_1(M_1))\right) + \left( w(A^+_1(M_2))-kw(A^-_1(M_2))\right) - 2kw(A^-_2(M_1)) \\ &=& \left( w(A^+_1(M_1))-kw(A^-_1(M_1))\right) + \left( w(A^+_1(M_2))-kw(A^-_1(M_2))\right) \\ &&~~~~~~~~~ - kw(A^-_2(M_1))-kw(A^-_2(M_2)) \\ &=& (\phi(M_1,M) - k\phi(M,M_1)) + (\phi(M_2,M) - k\phi(M,M_2)). \end{array} $$

Therefore, we have either ϕ(M1,M) > kϕ(M,M1) or ϕ(M2,M) > kϕ(M,M2), which implies u(M) > k. □

Since the weights of people are bounded by N = poly(n), the unpopularity factor u(M) must be in the form k = x/y, where x and y are integers not exceeding Nn. For a given value of k, if we multiply the weights of all edges of H(M,k) by y, they will be integers with magnitude O(Nn) = poly(n). Therefore, we can still use the algorithm of Duan et al. [7] to find a maximum weight perfect matching of H(M,k) with the same running time.

Moreover, there are at most O(N2n2) possible values of u(M). By performing a binary search on the value of k, we have to run the above algorithm for \(O(\log N^2n^2) = O(\log n)\) times as in the unweighted setting, hence the total running time is still \(O(m\sqrt {n}\log ^2 n)\).

The argument for mp instances still works for the weighted setting as well since H(M,k) is still bipartite, hence we have the following theorems for the weighted setting rp and mp.

Theorem 3

Given a weighted rp instance I with integer weights bounded by N = poly(n) and a matching M of I, there is an algorithm to compute u(M) in \(O(m\sqrt {n}\log ^2 n)\) time.

Theorem 4

Given a weighted mp instance I with integer weights bounded by N = poly(n) and a matching M of I, there is an algorithm to compute u(M) in \(O(m\sqrt {n}\log n)\) time.

5 Concluding Remarks

We develop an algorithm to compute the unpopularity factor of a given matching in \(O(m\sqrt {n}\log ^2 n)\) time for rp and \(O(m\sqrt {n}\log n)\) time for mp, which runs only slightly slower than the algorithm of McCutchen [20] to solve the same problem in hap and the algorithm of Biró et al. [5] to compute the unpopularity margin of a given matching in rp and mp. Our results also complete Tables 1 and 2, which show the running time of the currently best known algorithms related to popularity in rp, mp, and hap in the unweighted setting with strict preference lists, and with ties allowed, respectively. In both tables, m is the total length of preference lists, n is the total number of people and items, n2 is the number of items (for hap), and g is the unpopularity margin of a given matching.

Table 1 Currently best known algorithms for an unweighted instance with strict preference lists
Table 2 Currently best known algorithms for an unweighted instance with ties allowed in the preference lists

While the problem of finding a matching that minimizes the unpopularity factor or margin in a given matching is NP-hard, the problem of approximating the optimum of either measure is still open. For the unpopularity factor in rp with strict preference lists, the current best algorithm is the one developed by Huang and Kavitha [14], which approximates it up to \(O(\log n)\) factor. A possible future work is to investigate whether there is a better approximation algorithm for rp, or to develop one for hap. For the unpopularity margin, however, there is currently no efficient algorithm to approximate the optimum, both in rp and hap. Another possible future work is to investigate the probability of existence of a popular matching in rp where each person’s preference list is independently and uniformly generated at random, similarly to the study of Mahdian [18], and Ruangwises and Itoh [24] in hap.