Diverse collections in matroids and graphs

We investigate the parameterized complexity of finding diverse sets of solutions to three fundamental combinatorial problems. The input to the Weighted Diverse Bases problem consists of a matroid \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$M$$\end{document}M, a weight function \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\omega :E(M)\rightarrow \mathbb {N} $$\end{document}ω:E(M)→N, and integers \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$k\ge 1, d\ge 1$$\end{document}k≥1,d≥1. The task is to decide if there is a collection of \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$k$$\end{document}k bases \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$B_{1}, \dotsc , B_{k}$$\end{document}B1,⋯,Bk of \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$M$$\end{document}M such that the weight of the symmetric difference of any pair of these bases is at least \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$d$$\end{document}d. The input to the Weighted Diverse Common Independent Sets problem consists of two matroids \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$M_{1},M_{2}$$\end{document}M1,M2 defined on the same ground set \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$E$$\end{document}E, a weight function \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\omega :E\rightarrow \mathbb {N} $$\end{document}ω:E→N, and integers \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$k\ge 1, d\ge 1$$\end{document}k≥1,d≥1. The task is to decide if there is a collection of \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$k$$\end{document}k common independent sets \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$I_{1}, \dotsc , I_{k}$$\end{document}I1,⋯,Ik of \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$M_{1}$$\end{document}M1 and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$M_{2}$$\end{document}M2 such that the weight of the symmetric difference of any pair of these sets is at least \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$d$$\end{document}d. The input to the Diverse Perfect Matchings problem consists of a graph \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$G$$\end{document}G and integers \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$k\ge 1, d\ge 1$$\end{document}k≥1,d≥1. The task is to decide if \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$G$$\end{document}G contains \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$k$$\end{document}k perfect matchings \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$M_{1},\dotsc ,M_{k}$$\end{document}M1,⋯,Mk such that the symmetric difference of any two of these matchings is at least \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$d$$\end{document}d. We show that none of these problems can be solved in polynomial time unless \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${{\,\mathrm{\textsf{P}}\,}} ={{\,\mathrm{\textsf{NP}}\,}} $$\end{document}P=NP. We derive fixed-parameter tractable (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${{\,\mathrm{\textsf{FPT}}\,}}$$\end{document}FPT) algorithms for all three problems with \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$(k,d)$$\end{document}(k,d) as the parameter, and present a \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$poly(k,d)$$\end{document}poly(k,d)-sized kernel for Weighted Diverse Bases.


Introduction
In this work we study the parameterized complexity of finding diverse collections of solutions to three basic algorithmic problems.Two of these problems arise in the theory of matroids.The third problem belongs to the domain of graph theory, and its restriction to bipartite graphs can be rephrased as a question about matroids.Each of these is a fundamental algorithmic problem in its respective domain.

Diverse FPT Algorithms.
Nearly every existing approach to solving algorithmic problems focuses on finding one solution of good quality for a given input.For algorithmic problems which are-eventually-motivated by problems from the real world, finding "one good solution" may not be of much use for practitioners of the real-world discipline from which the problem was originally drawn.This is primarily because the process of abstracting out a "nice" algorithmic problem from a "messy" real-world problem invariably involves throwing out a lot of "side information" which is very relevant to the real-world problem, but is inconvenient, difficult, or even impossible to model mathematically.
The other extreme of enumerating all (or even all minimal or maximal) solutions to an input instance is also usually not a viable solution.A third approach is to look for a few solutions of good quality which are "far away" from one another according to an appropriate notion of distance.The intuition is that given such a collection of "diverse" solutions, an end-user can choose one of the solutions by factoring in the "side information" which is absent from the algorithmic model.These and other considerations led Fellows to propose the Diverse X Paradigm [9].Here "X" is a placeholder for an optimization problem, and the goal is to study the fixed-parameter tractability of finding a diverse collection of good-quality solutions for X.Recall that the Hamming distance of two sets is the size of their symmetric difference.A natural measure of diversity for problems whose solutions are subsets of some kind is the minimum Hamming distance of any pair of solutions.In this work we study the parameterized complexity of finding diverse collections of solutions for three fundamental problems with this diversity measure and its weighted variant.

Our problems.
Let M be a matroid on ground set E(M ) and with rank function r().The departure point of our work is the classical theorem of Edmonds from 1965 [6] about matroid partition.This theorem states that a matroid M has k pairwise disjoint bases if and only if, for every subset An important algorithmic consequence of this result is that given access to an independence oracle for a matroid M , one can find a maximum number of pairwise disjoint bases of M in polynomial time (See, e.g., [18,Theorem 42.5]).This in turn implies, for instance, that the maximum number of pairwise edge-disjoint spanning trees of a connected graph can be found in polynomial time.
We take a fresh look at this fundamental result of Edmonds: what happens if we don't insist that the bases be pairwise disjoint, and instead allow them to have some pairwise intersection?We work in the weighted setting where each element e of the ground set E(M ) has a positive integral weight ω(e) associated with it, and the weight of a subset X of E(M ) is the sum of the weights of the elements in X.The relaxed version of the pairwise disjoint bases problem is then: Given an independence oracle for a matroid M and integers k, d as input, find if M has k bases B 1 , . . ., B k such that for every pair of bases B i , B j ; i = j the weight ω(B i B j ) of their symmetric difference is at least d.We call this the Weighted Diverse Bases problem: A matroid M , a weight function ω : E(M ) → N, and integers k ≥ 1 and d ≥ 0. Task: Decide whether there are bases B1, . . ., B k of M such that ω(Bi Bj) ≥ d holds for all distinct i, j ∈ {1, . . ., k}.

Weighted Diverse Bases
Due to the expressive power of matroids Weighted Diverse Bases captures many interesting computational problems.We list a few examples; in each case the weight function assigns positive integral weights, k ≥ 1 and d ≥ 0 are integers, and we say that a collection of objects is diverse if the weight of the symmetric difference of each pair of objects in the collection is at least d.When M is a graphic matroid Weighted Diverse Bases corresponds to finding diverse spanning trees in an edge-weighted graph.When M is a vector matroid then this is the problem of finding diverse column (or row) bases of a matrix with column (or row) weights.And when M is a transversal matroid on a weighted ground set then this problem corresponds to finding diverse systems of distinct representatives.
Another celebrated result of Edmonds is the Matroid Intersection Theorem [7] which states that if M 1 , M 2 are matroids on a common ground set E and with rank functions r 1 , r 2 , respectively, then the size of a largest subset of E which is independent in both M 1 and M 2 (a common independent set) is given by min T ⊆E (r 1 (T ) + r 2 (E − T )).
Edmonds showed that given access to independence oracles for M 1 and M 2 , a maximumsize common independent set of M 1 and M 2 can be found in polynomial time [7].This is called the Matroid Intersection problem.Frank [12] found a polynomial-time algorithm for the more general Weighted Matroid Intersection problem where the input has an additional weight function ω : E → N and the goal is to find a common independent set of the maximum weight.The second problem that we address in this work is a "diverse" take on Weighted Matroid Intersection where we replace the maximality requirement on individual sets with a lower bound on the weight of their symmetric difference.Given M 1 , M 2 , ω as above and integers k, d, we ask if there are k common independent sets whose pairwise symmetric differences have weight at least d each; this is the Weighted Diverse Common Independent Sets problem.

Input:
Matroids M1 and M2 with a common ground set E, a weight function ω : E → N, and integers k ≥ 1 and d ≥ 0. Task: Decide whether there are sets I1, . . ., I k ⊆ E such that Ii is independent in both M1 and M2 for every i ∈ {1, . . ., k} and ω(Ii Ij) ≥ d for all distinct i, j ∈ {1, . . ., k}.

Weighted Diverse Common Independent Sets
Weighted Diverse Common Independent Sets also captures many interesting algorithmic problems.We give a few examples (cf.[18,Section 41.1a]).We use "diverse" here in the sense defined above.Given a bipartite graph G with edge weights, Weighted Diverse Common Independent Sets can be used to ask if there is a diverse collection of k matchings in G.A partial orientation of an undirected graph G is a directed graph obtained by (i) assigning directions to some subset of edges of G and (ii) deleting the remaining edges.Given an undirected graph G = (V, E) with edge weights and a function ι : V → N, we say that a partial orientation O of G respects ι if the in-degree of every vertex v in O is at most ι(v).We can use Weighted Diverse Common Independent Sets to ask if there is a diverse collection of k partial orientations of G, all of which respect ι.For a third example, let G = (V, E) be an undirected graph with edge weights, in which each edge is assigned a-not necessarily distinct-color.A colorful forest in G is any subgraph of G which is a forest in which no two edges have the same color.We can use Weighted Diverse Common Independent Sets to ask if there is a diverse collection of k colorful forests in G.
Finding whether a bipartite graph has a perfect matching or not is a well-known application of Matroid Intersection ([18, Section 41.1a]).The third problem that we study in this work is a diverse version of the former problem, extended to general graphs.Note that there is no known interpretation of the problem of finding perfect matchings in (general) undirected graphs in terms of Matroid Intersection.

Input:
An undirected graph G on n vertices, and integers k ≥ 1 and d ≥ 0. Task: Decide whether there are perfect matchings M1, . . ., M k of G such that |Mi Mj| ≥ d for all distinct i, j ∈ {1, . . ., k}.

Diverse Perfect Matchings
Our results.
We assume throughout that matroids in the input are given in terms of an independence oracle.Recall that with this assumption, we can find one basis of the largest weight and one common independent set (of two matroids) of the largest weight, both in polynomial time.
In contrast, we show that the diverse versions Weighted Diverse Bases and Weighted Diverse Common Independent Sets are both NP-hard, even when the weights are expressed in unary 1 .
Theorem 1.Both Weighted Diverse Bases and Weighted Diverse Common Independent Sets are strongly NP-complete, even on the uniform matroids U 3 n .
Given this hardness, we analyze the parameterized complexity of these problems with d, k as the parameters.Our first result is that Weighted Diverse Bases is fixed-parameter tractable (FPT) under this parameterization: We have a stronger result if the input matroid is given as a representation over a finite field (and not just as a "black box" independence oracle): in this case we show that Weighted Diverse Bases admits a polynomial kernel with this parameterization.Theorem 3. Given a representation of the matroid M over a finite field GF(q) as input, we can compute a kernel of Weighted Diverse Bases of size O(k 6 d 4 log q).
We then show that our second matroid-related diverse problem is also FPT under the same parameterization.

Theorem 4. Weighted Diverse Common Independent Sets can be solved in
We now turn to the problem of finding diverse perfect matchings.Diverse Perfect Matchings is known to be NP-hard already when k = 2 and G is a 3-regular graph [16,10].Since all perfect matchings of a graph have the same size the symmetric difference of two distinct perfect matchings is at least 2. Setting d = 1 in Diverse Perfect Matchings is thus equivalent to asking whether G has at least k distinct perfect matchings.Since a bipartite graph on n vertices has at most n 2 !perfect matchings and since log( n 2 !) = O(n log n) we get-using binary search-that there is a polynomial-time Turing reduction from the problem of counting the number of perfect matchings in a bipartite graph to Diverse Perfect Matchings instances with d = 1.Since the former problem is #P-complete [20] we get Theorem 5. Diverse Perfect Matchings with d = 1 cannot be solved in time polynomial in n = |V (G)| even when graph G is bipartite, unless P = NP.
Thus we get that Diverse Perfect Matchings is unlikely to have a polynomial-time algorithm even if one of the two numbers k, d is a small constant.We show that the problem does have a (randomized) polynomial-time algorithm when both these parameters are bounded; Diverse Perfect Matchings is (randomized) FPT with k and d as parameters: Theorem 6.There is an algorithm that given an instance of Diverse Perfect Matchings, runs in time 2 2 O(kd) n O (1) and outputs the following: If the input is a No-instance then the algorithm outputs No. Otherwise the algorithm outputs Yes with probability at least 1 − 1 e .
Note that Theorem 6 implies, in particular, that Diverse Perfect Matchings can be solved in (randomized) polynomial time when kd ≤ c 1 + log log n c2 holds for some constants c 1 , c 2 which depend on the constant hidden by the O() notation.

Our methods.
We prove the NP-hardness results (Theorem 1) by reduction from the 3-Partition problem.To show that Weighted Diverse Bases is FPT (Theorem 2) we observe first that if the input matroid M contains a set of size Ω(kd) which is both independent and co-independent in M then the input is a Yes instance of Weighted Diverse Bases (Lemma 10).We can check for the existence of such a set in time polynomial in |E(M )|, so we assume without loss of generality that no such set exists.We then show that starting with an arbitrary basis of M and repeatedly applying the greedy algorithm (Proposition 9) poly(k, d)-many times we can find, in time polynomial in (|E(M )| + k + d), (i) a subset S * ⊆ E(M ) of size poly(k, d) and (ii) a matroid M on the ground set S * such that ( M , ω, k, d) is equivalent to the input instance (M, ω, k, d) (Lemma 11).We also show how to compute a useful partition of E( M ) = S * which speeds up the subsequent FPT-time search for a diverse set of bases in M .The kernelization result for Weighted Diverse Bases (Theorem 3) follows directly from Lemma 11.This "compression lemma" is thus the main technical component of our algorithms for Weighted Diverse Bases.
To show that Weighted Diverse Common Independent Sets is FPT (Theorem 4) we observe first that if the two input matroids M 1 , M 2 have a common independent set of size Ω(kd) then the input is a Yes instance of Weighted Diverse Common Independent Sets (Lemma 16).So we assume that this is not the case, and then show (Lemma 17) that we can construct, in f (k, d) time, a collection F of common independent sets of M 1 and M 2 of size g(k, d) such that if the input is a Yes-instance then it has a solution I 1 , . . ., I k with I i ∈ F for i ∈ {1, . . ., k}.The FPT algorithm for Weighted Diverse Common Independent Sets follows by a simple search in the collection F.
Our algorithm for Diverse Perfect Matchings is based on two procedures.P1 Given an undirected graph G on n vertices, perfect matchings M 1 , . . ., M r of G, and a non-negative integer s as input, this procedure (Lemma 23) runs in time 2 Let (G, k, d) be the input instance of Diverse Perfect Matchings.We use procedure P1 to greedily compute a collection of matchings which are "far apart": We start with an arbitrary perfect matching M 1 .In step i, we have a collection of perfect matchings M 1 , . . ., M i−1 such that |M j M j | ≥ 2 k−i d holds for any two distinct j, j ∈ {1, . . ., i − 1}.We now run procedure P1 with r = i − 1 and s = 2 k−i d to find-if it exists-a matching M i such that |M i M j | ≥ 2 k−i+1 d holds for all j ∈ {1, . . ., i}.By exhaustively applying P1 we get a collection of perfect matchings M 1 , . . ., M q such that (a) for any two distinct integers i, j ∈ {1, . . ., q}, |M i M j | ≥ 2 k−q+1 d, and (b) for any other perfect matching Thus, if k ≤ q, then clearly {M 1 , . . ., M k } is a solution.Otherwise, let M = {M 1 , . . ., M k } be a hypothetical solution.Then for each M i there is a unique matching M j in {M 1 , . . ., M q } such that |M j M i | < 2 (k−q) d holds (Claim 28).For each i ∈ {1, . . ., q} we guess the number r i of perfect matchings from M that are close to M i , and use procedure P2 to compute a set of r i diverse perfect matchings that are close to M i .The union of all the matchings computed for all i ∈ {1, . . ., q} form a solution.
We use algebraic methods and color coding to design procedure P1.The Tutte matrix A of an undirected graph G over the field F 2 [X] is defined as follows, where F 2 is the Galois field on {0, 1} and X = {x e : e ∈ E(G)}.The rows and columns of A are labeled with V (G) and for each e = {u, v} ∈ E(G), A[u, v] = A[v, u] = x e .All other entries in A are zeros.There is a bijective correspondence between the set of monomials of det(A) and the set of perfect matchings of G. Procedure P1 extracts the required matching from det(A) using color coding.Procedure P2 is realized using color coding and dynamic programming.

Related work.
Recall that all bases of a matroid have the same size, and that the number of bases of a matroid on ground set E is at most 2 |E| .So using the same argument as for Theorem 5 we get that Weighted Diverse Bases generalizes-via Turing reductions-the problem of counting the number of bases of a matroid.Each of these reduced Weighted Diverse Bases instances will have d = 1, and a weight function which assigns the weight 1 to each element in the ground set.Counting the number of bases of a matroid is known to be #P-complete even for restricted classes of matroids such as transversal [3], bircircular [14], and binary matroids [21].Hence we have the following alternative2 hardness result for Weighted Diverse Bases The study of the parameterized complexity of finding diverse sets of solutions is a very recent development, and only a handful of results are currently known.In the work which introduced this notion Baste et al. [1] showed that diverse variants of a large class of graph problems which are FPT when parameterized by the treewidth of the input graph, are also FPT when parameterized by the treewidth and the number of solutions in the collection.In a second article [2] the authors show that for each fixed positive integer d, two diverse variants-one with the minimum Hamming distance of any pair of solutions, and the other with the sum of all pairwise Hamming distances of solutions-of the d-Hitting Set problem are FPT when parameterized by the size of the hitting set and the number of solutions.In a recent manuscript on diverse FPT algorithms [10] the authors show that the problem of finding two maximum-sized matchings in an undirected graph such that their symmetric difference is at least d, is FPT when parameterized by d.Note that our result on Diverse Perfect Matchings generalizes this to k ≥ 2 matchings, provided the input graph has a perfect matching.
In a very recent manuscript Hanaka et al. [15] propose a number of results about finding diverse solutions.We briefly summarize their results which are germane to our work.For a collection of sets X 1 , . . ., X k let d sum (X 1 , . . ., X k ) denote the sum of all pairwise Hamming distances of these sets and let d min (X 1 , . . ., X k ) denote the smallest Hamming distance of any pair of sets in the collection.Hanaka et al. show that there is an algorithm which takes an independence oracle for a matroid M and an integer k as input, runs in time polynomial in (|E(M )| + k), and finds a collection B 1 , B 2 , . . ., B k of k bases of M which maximizes d sum (B 1 , B 2 , . . ., B k ).This result differs from our work on Weighted Diverse Bases in two key aspects.They deal with the unweighted (counting) case, and their diversity measure is the sum of the pairwise symmetric differences, whereas we look at the minimum (weight of the) symmetric difference.These two measures are, in general, not comparable.
Hanaka et al. also look at the complexity of finding k matchings M 1 , . . ., M k in a graph G where each M i is of size t.They show that such collections of matchings maximizing 1) .The key difference with our work is that their algorithm looks for matchings of a specified size t whereas ours looks for perfect matchings, of size t = |V (G)| 2 ; note that this t does not appear in the exponential part of the running time of our algorithm (Theorem 6).The manuscript [15] has a variety of other interesting results on diverse FPT algorithms as well.

Organization of the rest of the paper.
In the next section we collect together some definitions and preliminary results.In Section 3 we prove that Weighted Diverse Bases and Weighted Diverse Common Independent Sets are strongly NP-hard.In Section 4 we derive our FPT and kernelization algorithms for Weighted Diverse Bases, and in Section 5 we show that Weighted Diverse Common Independent Sets is FPT.We derive our results for Diverse Perfect Matchings in Section 6.We conclude in Section 7.

Preliminaries
We use X Y to denote the symmetric difference (X \ Y ) ∪ (Y \ X) of sets X and Y .We use N to denote the set of positive integers.

Parameterized complexity.
A parameterized problem Π is a subset of Σ * × N, where Σ is a finite alphabet.We say that a parameterized problem Π is fixed parameter tractable (FPT), if there is an algorithm that given an instance (x, k) of Π as input, solves in time f (k)|x| O (1) , where f is an arbitrary function and |x| is the length of x.A kernelization algorithm for a parameterized problem Π is a polynomial time algorithm (computable function) for some computable function g.When g is a polynomial function, we say that Π admits a polynomial kernel.For a detailed overview about parameterized complexity we refer to the monographs [5,4,11] Matroids.
We give a brief description of the matroid-related notions that we need.See the book of Oxley [17] for a detailed introduction to matroids.A pair M = (E, I), where E is a finite ground set and I is a family of subsets of the ground set, called independent sets of E, is a matroid if it satisfies the following conditions, called independence axioms: We use E(M ) and I(M ) to denote the ground set and the set of independent sets, respectively.As is standard for matroid problems, we assume that each matroid M that appears in the input is given by an independence oracle, that is, an oracle that in constant (or polynomial) time replies whether a given A ⊆ E(M ) is independent in M or not.An inclusion-wise maximal independent set B is called a basis of M .We use B(M ) to denote the set of bases of M .The bases satisfy the following properties, called basis axioms: All the bases of M have the same size that is called the rank of M , denoted rank(M ).The rank of a subset A ⊆ E(M ), denoted rank(A), is the maximum size of an independent set X ⊆ A; the function rank : 2 Closures satisfy the following properties, called closure axioms: The dual of a matroid M = (E, I), denoted M * , is the matroid whose ground set is E and whose set of bases is That is, the bases of M * are exactly the complements of the bases of M .A basis (independent set, rank, respectively) of M * is a cobasis (coindependent set, corank, respectively) of M .We use I * (M ) to denote the set of coindependent sets of M .Also, corank(M ) denotes the corank of M and corank(A) denotes the corank of a set A ⊆ E(M ); corank(A) is the rank of set A in the dual matrix M * , and corank(A) = |A| − rank(M ) + rank(E \ A).Given an independence oracle for M we can construct-using the augmentation property (I3) and with an overhead which is polynomial in |E|-a rank oracle for M , and thence corank and coindependence oracles for M .*  .In particular, if e is not a loop (i.e., if {e} is independent) in M , then I(M ) = {X \ {e} | e ∈ X ∈ I(M )}.Notice that deleting an element in M is equivalent to contracting it in M * and vice versa.Let X ⊆ E(M ).Then M − X denotes the matroid obtained from M by the deletion of the elements of X and M/X is the matroid obtained by consecutive contractions of the elements of X.Note that an independence oracle for M can itself act as an independence oracle for M − X if we restrict our queries to subsets of E(M ) \ X.Let rank M/X denote the rank function of the matroid M/X.Then for any [17, 3.1.7].Given an independence oracle for M we can thus easily construct an independence oracle for M/X.
Let M be a matroid and let F be a field.An n × m-matrix A over F is a representation of M over F if there is one-to-one correspondence f between E(M ) and the set of columns of A such that for any X ⊆ E(M ), X ∈ I(M ) if and only if the columns f (X) are linearly independent (as vectors of F n ); if M has such a representation, then it is said that M has a representation over F. In other words, A is a representation of M if M is isomorphic to the linear matroid of A, i.e., the matroid whose ground set is the set of columns of A and a set of columns is independent if and only if these columns are linearly independent.Observe that, given a representation A of M , we can verify whether a set is independent by checking the linear independence of the corresponding columns of A. Hence, we don't need an explicit independence oracle in this case.
Let 1 ≤ r ≤ n be integers.We use U r n to denote the uniform matroid, that is, the matroid with the ground set of size n such that the bases are all r-element subsets of the ground set.
We use the classical results of Edmonds [7] and Frank [12] about the Weighed Matroid Intersection problem.The task of this problem is, given two matroids M 1 and M 2 with the same ground set E and a weight function ω : E → N, find a set X of maximum weight such that X is independent in both matroids.Edmonds [7] proved that the problem can be solved in polynomial time for the unweighted case (that is, the task is to find a common independent set of maximum size; we refer to this variant as Matroid Intersection) and the result was generalized for the variant with the weights by Frank in [12].Proposition 8 ([7, 12]).Weighted Matroid Intersection can be solved in polynomial time.
We also need another classical result of Edmonds [8] that a basis of maximum weight can be found by the greedy algorithm.Recall that, given a matroid M with a weight function ω : E(M ) → N, the greedy algorithm finds a basis B of maximum weight as follows.Initially, B := ∅.Then at each iteration, the algorithm finds an element of x ∈ E(M ) \ B of maximum weight such that B ∪ {x} is independent and sets B := B ∪ {x}.The algorithms stops when there is no element that can be added to B.

Proposition 9 ([8]). The greedy algorithm finds a basis of maximum weight of a weighted matroid in polynomial time.
We need the following observation(See [17, Lemma 2.1.10]).
Observe that for any sets X and Y that are subsets of the same universe, X Y = X Y .This implies the following.

Hardness of Weighted Diverse Bases and Weighted Diverse Common Independent Sets
We show that Weighted Diverse Bases and Weighted Diverse Common Independent Sets are NP-complete in the strong sense even for uniform matroids.
Theorem 1.Both Weighted Diverse Bases and Weighted Diverse Common Independent Sets are strongly NP-complete, even on the uniform matroids U 3 n .
Proof.We prove the claim for Weighted Diverse Bases by a reduction from the 3-Partition problem.The input to 3-Partition consists of a positive integer b and a multiset S = {s 1 , . . ., s 3n } of 3n positive integers such that (i) b 4 < s i < b 2 holds for each i ∈ {1, . . ., 3n} and (ii) 3n i=1 s i = nb.The task is to decide whether S can be partitioned into n multisets S 1 , . . ., S n such that s∈Si s = b holds for each S i .Note that each multiset S i in such a partition must contain exactly three elements from S. This problem is known to be NP-complete in the strong sense, i.e., it is NP-complete even if the input integers are encoded in unary [13,SP15].
Let (b, S = {s 1 , . . ., s 3n )} be an instance of 3-Partition with n ≥ 3. We set M to be the uniform matroid U 3 3n on the ground set {1, . . ., 3n}, and define the weight function to be ω(i) = s i for i ∈ {1, . . ., 3n}.We set d = 2b.We will now show that (b, S) is a yes-instance of 3-Partition if and only if (M, ω, n, d) is a yes-instance of Weighted Diverse Bases.
In the forward direction, suppose that S 1 , . . ., S n is a partition of S into triples of integers such that the sum of elements of each S i is b.Let B 1 , . . ., B n be the corresponding partition of {1, . . ., 3n}, that is, Clearly, B 1 , . . ., B n are pairwise disjoint bases of M .Then for every distinct i, j ∈ {1, . . ., n}, ω(B i B j ) = ω(B i ) + ω(B j ) = 2b.Therefore, (M, ω, n, d) is a yes-instance of Weighted Diverse Bases.
In the reverse direction, assume that (M, ω, n, d) is a yes-instance of Weighted Diverse Bases.Let B 1 , . . ., B n be bases of M such that ω(B i B j ) ≥ d = 2b for distinct i, j ∈ {1, . . ., n}.
Next we show that ω(B i ) = b holds for every i ∈ {1, . . ., n}.Suppose that there is an h ∈ {1, . . ., n} such that ω(B h ) > b.Let I = {1, . . ., 3n} \ B h and J = {1, . . ., n} \ {h}.We have that i∈I ω(i) < The first inequality above comes from the fact that since |J| = n − 1, for each index i ∈ J the term ω(B i ) appears in at most n − 2 terms of the form (ω(B i ) + ω(B j )) in the summation on the left hand side.Now suppose (ω(B i ) + ω(B j )) ≥ 2b holds for all pairs i, j ∈ J, i = j.Then the sum on the left hand side would be at least |J| 2 • 2b = (n − 1)(n − 2)b, a contradiction.Therefore, there must exist distinct i, j ∈ J such that ω(B i ) + ω(B j ) < 2b holds.And this contradicts our assumption that ω(B i B j ) ≥ 2b holds for all such i, j.We conclude that ω(B i ) ≤ b holds for every i ∈ {1, . . ., n}.And since n i=1 ω(B i ) = bn, we get that ω(B i ) = b holds for every i ∈ {1, . . ., n}.
Finally, we consider the partition S 1 , . . ., S n of S corresponding to B 1 , . . ., B i , that is, for each Thus we get that (b, S) is a yes-instance of 3-Partition.This concludes the proof for Weighted Diverse Bases.
The reduction for Weighted Diverse Common Independent Sets is also from 3-Partition, and is nearly identical to the above reduction for Weighted Diverse Bases.Given an instance (b, S = {s 1 , . . ., s 3n )} of 3-Partition with n ≥ 3, we set each of M 1 , M 2 to be the uniform matroid U 3 3n on the ground set {1, . . ., 3n}, and define the weight function to be ω(i) = s i for i ∈ {1, . . ., 3n}.We set d = 2b.We will now show that (b, S) is a yes-instance of 3-Partition if and only if (M 1 , M 2 , ω, n, d) is a yes-instance of Weighted Diverse Common Independent Sets.
In the forward direction, suppose that S 1 , . . ., S n is a partition of S into triples of integers such that the sum of elements of each S i is b.Let I 1 , . . ., I n be the corresponding partition of {1, . . ., 3n}, that is, Clearly, I 1 , . . ., I n are pairwise disjoint common independent sets of M 1 and M 2 , and for every distinct i, j ∈ {1, . . ., n}, ω(I i I j ) = ω(I i ) + ω(I j ) = 2b.Therefore, (M 1 , M 2 , ω, n, d) is a yes-instance of Weighted Diverse Common Independent Sets.
In the reverse direction, assume that (M 1 , M 2 , ω, n, d) is a yes-instance of Weighted Diverse Common Independent Sets, and let I 1 , . . ., I n be common independent sets of M 1 and M 2 such that ω(I i I j ) ≥ d = 2b for distinct i, j ∈ {1, . . ., n}.Since every independent set in the matroids M 1 , M 2 has at most three elements, and since s i < b 2 holds for each i ∈ {1, . . ., 3n}, we get that the sets I 1 , . . ., I n are pairwise disjoint.If two of these sets, say I i , I j have at most two elements each then ω(I i I j ) < 4 • b 2 = 2b, a contradiction.So at most one of these sets has at most two elements; every other set in the collection has exactly three elements.
If all the sets I 1 , . . ., I n have three elements each then they are a pairwise disjoint collection of n bases of M 1 , and the argument that we used for the reverse direction in the proof for Weighted Diverse Bases tells us that (b, S) is a yes-instance of 3-Partition.In the remaining case there is exactly one set of size two among I 1 , . . ., I n ; without loss of generality, let this smaller set be I i be the unique element which is not in any of these independent sets.Then (I 1 ∪ {x}), . . ., I n is a pairwise disjoint collection of n bases of M 1 such that the weight of the symmetric difference of any pair of these bases is at least d = 2b, and the argument that we used for the reverse direction in the proof for Weighted Diverse Bases tells us that (b, S) is a yes-instance of 3-Partition.

4
An FPT algorithm and kernelization for Weighted Diverse Bases In this section, we show that Weighted Diverse Bases is FPT when parameterized by k and d.Moreover, if the input matroid is representable over a finite field and is given by such a representation, then Weighted Diverse Bases admits a polynomial kernel.
We start with the observation that if the input matroid has a sufficiently big set that is simultaneously independent and coindependent, then diverse bases always exist.Lemma 10.Let M be a matroid, and let k ≥ 1 and d ≥ 0 be integers.If there is X ⊆ E(M ) of size at least k d 2 such that X is simultaneously independent and coindependent, then (M, ω, k, d) is a yes-instance of Weighted Diverse Bases for any weight function ω.
Proof.Let X ⊆ E(M ) be a set of size at least k d 2 such that X is simultaneously independent and coindependent.Then there is a partition X 1 , . . ., X k of X such that |X i | ≥ d 2 for every i ∈ {1, . . ., k}.Let i ∈ {1, . . ., k}.Since X is independent, X i is independent, and since X is coindependent, then X \ X i is coindependent.Then by Observation 1, there is a basis B i of M such that X i ⊆ B i and B i ∩ (X \ X i ) = ∅.The latter property means that B i ∩ X j = ∅ for every j ∈ {1, . . ., k} such that j = i.We consider the bases B i defined in this manner for all i ∈ {1, . . ., k}.Then for every distinct i, j ∈ {1, . . ., k}, Hence, (M, ω, k, d) is a yes-instance of Weighted Diverse Bases.
Our results are based on the following lemma.Proof.Let (M, ω, k, d) be an instance of Weighted Diverse Bases.Recall that M is given as an independence oracle.We construct an independence oracle for the dual matroid M * , and then solve Matroid Intersection for M and M * using Proposition 8. Let X be the set computed by the Matroid Intersection algorithm.Then X ⊆ E(M ) is a set of maximum size that is both independent and coindependent in M .If |X| ≥ k d 2 , then (M, ω, k, d) is a yes-instance of Weighted Diverse Bases by Lemma 10; the problem is solved and we return the answer.
Assume from now on that this is not the case, and that |X| ≤ k .Fix an arbitrary basis B of M .We construct sets S 0 , . . ., S iteratively.We set S 0 = B.For i ≥ 1 we construct S i from S (i−1) as follows.If E(M ) \ S i−1 = ∅, we set X i = ∅.Otherwise we set X i to be a basis of maximum weight in the matroid M − S i−1 ; we find X i using the greedy algorithm (see Proposition 9).Finally, we set S i = S i−1 ∪ X i .
Let S = S and L = S \ B. Since rank(B) ≤ k d 2 − 1, we get that every independent set contained in the set B = (E(M ) \ B) has size at most k d 2 − 1.And since L is a disjoint union of such independent sets we get that We show the following crucial claim.
Claim 12.If (M, ω, k, d) is a yes-instance of Weighted Diverse Bases, then there is a solution, that is, a family of bases B 1 , . . ., B k such that ω(B i B j ) ≥ d for all distinct i, j ∈ {1, . . ., k}, with the property that B i ⊆ S for every i ∈ {1, . . ., k}.
Proof.Let (M, ω, k, d) be a yes-instance, and let the family of bases B 1 , . . ., B k be a solution which maximizes the size of the set (( k i=1 B i ) ∩ S) of vertices in the bases which are also in the set S. We show that B i ⊆ S holds for every i ∈ {1, . . ., k}.The proof is by contradiction.Assume that there is an h ∈ {1, . . ., k} such that . ., X be the independent sets used to construct the sets S 1 , . . ., S .Since (X j ∩ B) = ∅ holds for all j ∈ {1, . . ., } we get that (X j ∩ B i ) = (X j ∩ (B i \ B)) holds for all i ∈ {1, . . ., k}, j ∈ {1, . . ., }.So the number | ∪ k i=1 (B i \ B)| of elements from the bases B 1 , . . ., B k which could potentially be part of any of the sets X 1 , . . ., X is strictly less than the number of these latter sets.Hence from the pigeonhole principle we get that there is a t ∈ {1, . . ., } such that X t ∩ B i = ∅ holds for all i ∈ {1, . . ., k}.
We construct Z by greedily augmenting A with elements of X t .Let σ be the order in which the greedy algorithm picks elements from the set E(M ) \ S (t−1) to add them to the set X t .Initially we set Z := ∅.Then we select the first x ∈ X t \ Z in σ such that A ∪ Z ∪ {x} is independent, and we set Z := Z ∪ {x}.We stop when there is no x ∈ X t \ Z such that A ∪ Z ∪ {x} is independent.We prove that (i) and (ii) are fulfilled for Z.
First we show that (i) holds.From the construction we get that X t is a basis of the matroid M − S (t−1) .This implies that (E(M ) \ S (t−1) ) ⊆ cl(X t ) holds.Now since Y = (B h \ S (t−1) ) is We now repeat the argument that preceded Claim 12, this time with the dual matroid M * and starting with its basis B = (E( M ) \ B) = L. Recall that = d 2 k 2 .We construct sets S * 0 , . . ., S * iteratively.We set S * 0 = B.For i ≥ 1 we construct S * i from S * (i−1) as follows.If E( M ) \ S * i−1 = ∅, we set X * i = ∅.Otherwise we set X * i to be a basis of maximum weight in the matroid M * − S * i−1 , which we find using the greedy algorithm.Finally, we set  M , ω, k, d) is a yes-instance of Weighted Diverse Bases, then there is a solution, that is, a family of bases B 1 , . . ., B k such that ω(B i B j ) ≥ d for all distinct i, j ∈ {1, . . ., k} with the property that B i ⊆ S * for every i ∈ {1, . . ., k}, where Hence from Claim 14 we get that if ( M , ω, k, d) is a yes-instance, then it has a solution B 1 , . . ., B k such that (B \ S * ) ⊆ B i holds for every i ∈ {1, . . ., k}.That is, elements from the set (B \ S * ) do not contribute to the weight ω(B i B j ) for any distinct i, j ∈ {1, . . ., k}.So a transformation that removes the subset (B \ S * ) from the ground set of M is safe, provided that (i) To show the second claim of the lemma, assume that we are given representation A of M over a finite field F. It is well-known that M * also is representable over F and, given A, the representation of M * over F can be computed in polynomial time by linear algebra tools (see, e.g., [17]).Taking into account that contraction of a set is equivalent to the deletion of the same set in the dual matroid and vice versa, we obtain that the representation Ã of M can be constructed in polynomial time from A. This concludes the proof of the lemma.
Using Lemma 11 we can prove that Weighted Diverse Bases is FPT when parameterized by k and d.If the input matroid is given by a representation over a finite field, then Weighted Diverse Bases admits a polynomial kernel when parameterized by k and d.Theorem 3. Given a representation of the matroid M over a finite field GF(q) as input, we can compute a kernel of Weighted Diverse Bases of size O(k 6 d4 log q).(M, ω, k, d) be an instance of Weighted Diverse Bases.Let also A be its representation over GF(q).We run the algorithm from Lemma 11.If the algorithm solves the problem and reports that (M, ω, k, d) is a yes-instance, we return a trivial yes-instance of the problem.Otherwise, the algorithm outputs an equivalent instance ( M , ω, k, d

Proof. Let
An FPT algorithm for Weighted Diverse Common Independent Sets In this section we show that Weighted Diverse Common Independent Sets is FPT when parameterized by k and d.
We use a similar win-win approach as for Weighted Diverse Bases and observe that if the two matroids from an instance of Weighted Diverse Common Independent Sets have a sufficiently big common independent set, then we have a yes-instance of Weighted Diverse Common Independent Sets.

Lemma 16.
Let M 1 and M 2 be matroids with a common ground set E, and let k ≥ 1 and d ≥ 0 be integers.If there is an Proof.Let X ⊆ E be a set of size at least k d 2 such that X is a common independent set of M 1 and M 2 .Then there is a partition I 1 , . . ., I k of X such that |I i | ≥ d 2 for every i ∈ {1, . . ., k}.Clearly, I 1 , . . ., I k are common independent sets of M 1 and M 2 .Also we have that ω(I i I j ) = ω(I i ) + ω(I j ) ≥ d for all distinct i, j ∈ {1, . . ., k} and every weight function ω which assigns positive integral weights.This means that I 1 , . . ., I k is a solution for Lemma 16 implies that we can assume that the maximum size of a common independent set of the input matroids is bounded.We prove the following crucial lemma.Lemma 17.Let (M 1 , M 2 , ω, k, d) be an instance of Weighted Diverse Common Independent Sets such that the maximum size of a common independent set of M 1 and M 2 is at most s.Then there is a set F of common independent sets of M 1 and M 2 , of size ω, k, d) is a yes-instance of Weighted Diverse Common Independent Sets then the instance has a solution I 1 , . . ., I k with I i ∈ F for i ∈ {1, . . ., k}.Moreover, F can be constructed in 2 O(s 2 log(ks)) • d • |E| O (1) time where E is the (common) ground set of M 1 and M 2 .
It is convenient to assume that the weights of the elements are bounded by d.For this, we set ω(e) := min{d, ω(e)} for every e ∈ E. It is straightforward to see that by this operation we obtain an equivalent instance of Weighted Diverse Common Independent Sets.Notice that for every common independent set I of M 1 , M 2 , we now have ω(I) ≤ ds.
For every w ∈ {0, . . ., ds}, we use a recursive branching algorithm to construct a family F w of size 2 O(s 2 log(ks)) of common independent sets of M 1 and M 2 with the following properties: (i) each set in F w has weight at least w, and (ii ω, k, d) such that ω(I i ) = w for some i ∈ {1, . . ., k}, then there is an The algorithm, denoted by A, takes as its input a common independent set X of M 1 and M 2 , and two matroids M 1 and M 2 such that M i = (M i − W )/X for i = 1, 2 for some subset W ⊆ E \ X.For the very first call to A we set X := ∅ and M i = M i for i = 1, 2 (thus we implicitly set W := ∅).Algorithm A outputs at most ks common independent sets of M 1 and M 2 of the form X ∪ Y , where Algorithm A performs the following steps.
Step 1.If ω(X) ≥ w, then output X and return.For each nonempty common independent set This completes the description of A. To construct F w , we call A(∅, M 1 , M 2 ).Then the set F w includes all the sets output by A. Note that in every recursive step we call So the size of the first argument (X ∪ Z) to a recursive call of A is strictly larger than the size of the first argument X of the parent call to A. Moreover, since Z is a common independent set of M 1 and M 2 , we have that X ∪ Z is a common independent set of M 1 and M 2 .Because the maximum size of the common independent set of M 1 and M 2 is at most s, we obtain that the depth of the recursion is bounded by s, that is, the algorithm is finite.We show the crucial property of F w mentioned above.
Claim 18.If S = {I 1 , . . ., I k } is a solution to the instance (M 1 , M 2 , ω, k, d) such that ω(I i ) = w for some i ∈ {1, . . ., k}, then there is an Proof.Fix a set I i ∈ S ; ω(I i ) = w.Recall that an arbitrary invocation of A has the form A(X, (M 1 − W )/X, (M 2 − W )/X) where X is a common independent set of M 1 , M 2 and W ⊆ (E \ X).For the very first invocation of A these sets are X = ∅, W = ∅, and these sets trivially satisfy the viability condition (X ∪ W ) ∩ I i = X; that is: I i contains all of X, and none of W .We show that any invocation of A whose arguments satisfy the viability condition either outputs a set I i that can be used to replace I i in S, or makes at least one recursive call to A such that the arguments to this recursive call satisfy the viability condition.Since the size of the first argument (X ∪ Z) to a recursive call of A is strictly larger than the size of the first argument X of the parent call to A, we get that some call to A will output a set I i with the desired property.
Assume inductively that A(X, ) is an invocation of A whose arguments satisfy the viability condition.If ω(X) ≥ w, then X = I i , because ω(I i ) = w.In this case, the algorithm outputs X = I i in Step 1.Clearly, we can set I i = I i , and we are done.So let us assume that this is not the case, and that ω(X) < w.In this case X I i holds and the algorithm goes to Step 2.
Let E = E \ (X ∪ W ) be the common ground set of M 1 and M 2 .Let Y = (I i \ X) and w = ω(Y ) = w − ω(X).Then since Y is a common independent set of M 1 and M 2 , the greedy computation of Step 2 produces a nonempty family Y 1 , . . ., Y of disjoint common independent sets of M 1 and M 2 of weight at least w each.Note that X ∪ Y 1 , . . ., X ∪ Y are common independent sets of M 1 and M 2 .We consider two cases depending on the value of in Step 3. Note that by the above reasoning the case = 0 does not arise here.
, where the last equation follows from the fact that X ⊆ I i holds.From this chain of relations we also get that ω(I i \ X) ≤ ω(Y h ) holds.Consider an arbitrary index j ∈ {1, . . ., k} ; j = i.Then ω( Thus ω(I j I i ) ≥ ω(I i I j ), and so replacing I i by I i in the solution S indeed gives us a solution to the instance (M 1 , M 2 , ω, k, d).Case 2. 0 < < ks.In this case we set R := i=1 Y i .From the construction we get that the matroids M 1 −R and M 2 −R have no common independent set of weight at least w .Since (I 1 \ X) \ R is such a common independent set we have that ω((I 1 \ X) \ R) < w , and since ω( Clearly, Z is a common independent set of M 1 and M 2 .Our algorithm considers all such sets.Hence there is a recursive call By the choice of Z and W we get that (X ∪ W ) ∩ I i = X , so that this recursive call satisfies the viability condition.Moreover, we have that |X | > |X|.This completes the second case and the proof of the claim.
We already observed that the algorithm A is finite.Now we evaluate its running time and the size of F w .Claim 19.The set F w has size 2 O(s 2 log(ks)) and can be constructed in 2 O(s 2 log(ks)) • |E| O(1)  time.
Proof.To give an upper bound on the size of F w , observe that in each recursive call, the algorithm A either outputs some sets, or performs some recursive calls, or simply returns without outputting anything.Notice that in Step 1, A can output at most one set, and A may output ks sets in Step 3. The number of recursive calls is upper bounded by the number of nonempty common independent sets Z ⊆ R of M 1 and M 2 .Since < ks and |Y i | ≤ s for i ∈ {1, . . ., }, |R| ≤ ks 2 .Because for each Z, |Z| ≤ s, the branching factor is at most (ks 2 ) s = 2 O(s log(ks)) .Since the depth of the recursion is at most s, the search tree has 2 O(s 2 log(ks)) leaves.This implies that the size of F w is 2 O(s 2 log(ks)) .
To evaluate the running time, note that in Step 2, the algorithm greedily constructs the sets Y 1 , . . ., Y that are common independent sets of M 1 and M 2 .By Proposition 8, this can be done in polynomial time, because in each iteration we find a common independent set of maximum weight.Because the search tree has 2 O(s 2 log(ks)) leaves, the total running time is 2 O(s 2 log(ks)) • |E| O (1) .
We construct F = Proof.Let (M 1 , M 2 , ω, k, d) be an instance of Weighted Diverse Common Independent Sets.First, we use Proposition 8 to solve Matroid Intersection for M 1 and M 2 and find a common independent set X of maximum size.If |X| ≥ k d 2 , then by Lemma 16, we conclude that (M 1 , M 2 , ω, k, d) is a yes-instance.Assume that this is not the case.Then the maximum size of a common independent set of M 1 and M 2 is s < k d 2 .We apply Lemma 17 and construct the set F of size 2 O((kd) 2 log(kd)) in 2 O((kd) 2 log(kd)) • |E| O(1) time.By this lemma, if (M 1 , M 2 , ω, k, d) is a yes-instance, it has a solution I 1 , . . ., I k such that I i ∈ F for i ∈ {1, . . ., k}.Hence, to solve the problem we go over all k-tuples of the elements of F, and for each k-tuple, we verify whether these common independent sets of M 1 and M 2 give a solution.Clearly, we have to consider 2 O(k 3 d 2 log(kd)) tuples.Hence, the total running time is 2 O(k 3 d 2 log(kd)) • |E| O (1) .

Perfect Matchings
In this section we prove that Diverse Perfect Matchings is fixed parameter tractable when parameterized by k and d.We need the following simple observations later in this section.

Observation 3. The cardinality of symmetric differences of perfect matchings in a graph obeys the triangle inequality. That is, for a graph G and perfect matchings
Observation 3 follows from the fact that Hamming distance is a metric and hence obeys triangular inequality.Observation 4. Let G be a graph and M 1 and M 2 be two perfect matchings in G.
For an undirected graph G, the Tutte matrix A of G over the field F 2 [X] is defined as follows, where F 2 is the Galois field on {0, 1} and X = {x e : e ∈ E(G)}.The rows and columns of A are labeled with V (G) and for each e = {u, v} ∈ All other entries in the matrix are zeros.That is, for any pair of vertices u, v ∈ V (G), if there is no edge between u and v, A[u, v] = 0.It is well known that det(A) = 0 if and only if G has a perfect matching.As the characterstic of F 2 is a 2, the determinant of A coincides with the permanent of A. That is, Here, S V (G) is the set of all permutations of V (G).Let PM(G) be the set of perfect matchings on G.Then, one can show that det(A) = M ∈PM(G) Π e∈M x 2 e .Let Y be a set of variables disjoint from X.For each edge e, let L(e) ⊆ Y be a subset of variables.Let A be the matrix obtained from A by replacing each entry of the form x e with x e • Π y∈L(e) y.Then, where Lemma 20.Let G be an undirected graph and let X = {x e : e ∈ E(G)} and Y = {y 1 , . . ., y } be two sets of variables such that X ∩ Y = ∅.For each edge e ∈ E(G), we are also given a subset L(e) ⊆ Y .Let A be the matrix defined as above.For any perfect matching M , Π e∈M x 2 e Π y∈L(e) y 2 is a monomial in det(A ).Moreover, for any monomial m in det(A ), M = {e : x e is a variable in m} is perfect a matching in G and for each e ∈ M , L(e) is a subset of variables in the monomial m.
and each connected component of G[F ] is either a cycle or an edge.Each non-zero term in the summation of (2), there is a cycle-matching cover defined as follows.
Let F be a cycle-matching cover.Let {C 1 , . . ., C r } be the set of cycles in G[F ] and {e 1 , . . ., e s } be the set of the edges in F \ , where > 2 one can define two permutations σ 1 and σ 2 on V (C) as follows: (u 1 , u 2 , . . ., u ) and (u 1 , u , u −1 , . . ., u 2 ).That is, This implies that there are 2 r terms in (2)  As any non-zero term in (2) corresponds to a cycle-matching cover, and for any cycle matching cover that contains at least one cycle all the terms corresponding to it cancels each other we have the following.For any monomial m in det(A ), M = {e : x e is a variable in m} is perfect a matching in G. Also, from the construction of A , it follows that for each e ∈ M , L(e) is subset of variables in m.
We use the following two known results.
Proposition 21 23]).Let P (x 1 , . . ., x n ) be a multivariate polynomial of total degree at most d over a field F, and P is not identically zero.Let r 1 , . . ., r n be the elements in F choses uniformly at random with repetition.Then Pr(P (r 1 , ..., r n ) = 0) ≤ d |F| .
Claim 26.For any two distinct integers i, j ∈ . Similarly, we have E j,2 ⊆ S j \ S i .That is, we prove that E i,1 ∪ E j,2 ⊆ S j \ S i and E j,1 ∪ E i,2 ⊆ S i \ S j .Also, since all the edges in S gets distinct colors and the colors on the edges in S i and S j are C i and C j , respectively, we have that |C i C j | ≥ |E i ∪ E j | ≥ d.This completes the proof of the claim.
Next we prove the reverse direction of the above claim.Proof.As M is a perfect matching and Q 1 is a collection of alternating cycles, we have that P 1 = E(Q 1 ) M is a perfect matching.By similar arguments, we have that P 2 is a perfect matching.Now we prove that E(Q 1 ) E(Q 2 ) ⊆ P 1 P 2 .Consider an edge e ∈ E(Q 1 ) \ E(Q 2 ).We have two cases based on whether e ∈ M or not.In the first case, assume that e ∈ M .Since e ∈ E(Q 1 ), e ∈ M , and P 1 = E(Q 1 ) M , we have that e / ∈ P 1 .Also since e / ∈ E(Q 2 ), e ∈ M , and P 2 = E(Q 2 ) M , we have that e ∈ P 2 .Therefore, e ∈ P 1 P 2 .
For the second case, we have that e / ∈ M .Since e ∈ E(Q 1 ), e / ∈ M , and P 1 = E(Q 1 ) M , we have that e ∈ P 1 .Also, since e / ∈ E(Q 2 ) and e / ∈ M , we have that e / ∈ P 2 .Therefore, e ∈ P 1 P 2 .
By arguments, similar to above, one can prove that an edge e ∈ E(Q 2 ) \ E(Q 1 ) also belongs to P 1 P 2 .Thus, we proved that E(Q 1 ) E(Q 2 ) ⊆ P 1 implies that for any two distinct i, j ∈ {1, . . ., q}, the cardinality of the symmetric difference between a matching in {N i,1 , . . ., N i,ri } and a matching in {N j,1,...,Nj,r j } is at least d.
If algorithm A computes a solution in any of the guesses for r 1 , . . ., r d , then we output Yes.Otherwise we output No.As the number of choices for r 1 , . . .r k is upper bounded by k O(k) , from Lemmas 23 and 25 we get that the running time of A is 2 2 O(kd) n O (1) and the success probability is at least 2 −2 ckd for some constant c.To get success probability 1 − 1/e, we do 2 2 ckd many executions of A and output Yes if we succeed in at least one of the iterations and output No otherwise.Thus, running time of the overall algorithm is 2 2 O(kd) n O (1) .

Conclusion
We took up weighted diverse variants of two classical matroid problems and the unweighted diverse variant of a classical graph problem.We showed that the two diverse matroid problems are NP-hard, and that the diverse graph problem cannot be solved in polynomial time even for the smallest sensible measure of diversity.We then showed that all three problems are FPT with the combined parameter (k, d) where k is the number of solutions and d is the diversity measure.We conclude with a list of open questions: We showed that the unweighted, counting variant of Weighted Diverse Bases does not have a polynomial-time algorithm unless P = NP (Theorem 7).This is the case when all the weights are 1 and d = 1 or d = 2.Both the weighted and unweighted variants can be solved in polynomial time when k = 1 (the greedy algorithm) and k = 2 ((weighted) matroid intersection).What happens for larger, constant values of d and/or k? Till what values of d, k does the problem remain solvable in polynomial time?These questions are interesting also for special types of matroids.For instance, is there a polynomial-time algorithm that checks if an input graph has three spanning trees whose edge sets have pairwise symmetric difference at least d, or is this already NP-hard?A potentially easier question along the same vein would be: we know from Theorem 7 that Weighted Diverse Bases is unlikely to have an FPT algorithm parameterized by d alone.Is Weighted Diverse Bases FPT parameterized by k alone?Unlike for the other two problems, we don't have hardness results for Weighted Diverse Common Independent Sets for small values of k or d.Is Weighted Diverse Common Independent Sets FPT when parameterized by either d or k?Is this problem in P when all the weights are 1?

Theorem 7 .
Weighted Diverse Bases cannot be solved in time polynomial in |E(M )| unless P = NP, even when d = 1 and every element of the ground set E(M ) has weight 1.
For e ∈ E(M ), the matroid M = M − e is obtained by deleting e if E(M ) = E(M ) \ {e} and I(M ) = {X ∈ I(M ) | e / ∈ X}.It is said that M = M/e is obtained by contracting e if M = (M * − e)

Lemma 11 . 2 2 k 3 .
There is an algorithm that, given an instance (M, ω, k, d) of Weighted Diverse Bases, runs in time polynomial in (|E(M )| + k + d) and either correctly decides that (M, ω, k, d) is a yes-instance or outputs an equivalent instance ( M , ω, k, d) of Weighted Diverse Bases such that E( M ) ⊆ E(M ) and |E( M )| ≤ 2 d In the latter case, the algorithm also computes a partition (L, L * ) of E( M ) with the property that for every basis B of M , |B ∩ L| ≤ d 2 k and |L * \ B| ≤ d 2 k, and the algorithm outputs an independence oracle for M that answers queries for M in time polynomial in |E(M )|.Moreover, if M is representable over a finite field F and is given by such a representation, then the algorithm outputs a representation of M over F.

2 2 k 3 2 2 k 3 , 2 2 k 3 .
is a basis of the resulting matroid for all i ∈ {1, . . ., k}, and (ii) for any basis B of the resulting matroid, B ∪ (B \ S * ) is a basis of M .We now show that the operation of contracting the set (B \ S * ) has both these properties.Let M = M /(B \ S * ).Then E( M ) = (B ∪ S * ) \ (B \ S * ) = S * .Let rank( M ), rank( M ) be the ranks and rank, rank be the rank functions of the two matroids M , M , respectively.Recall that rank(X) = rank((B \ S * ) ∪ X) − rank(B \ S * ) holds for all X ⊆ E( M ) = S * .Now rank( M ) = rank(S * ) = rank(B ∪ S * ) − rank(B \ S * ) = rank( M ) − |B \ S * |,where the last equation holds because B is a basis of M .And for any i ∈ {1, . . ., k}, rank(B i ∩ S * ) = rank((B \ S * ) ∪ (B i ∩ S * )) − rank(B \ S * ) = rank( M ) − |B \ S * | = rank( M ), where the second equation holds because B, B i are bases of M and B i ⊆ ((B \ S * ) ∪ (B i ∩ S * )).Thus (B i ∩ S * ) is a basis of M .Finally, let B be an arbitrary basis of M .Then rank(B ) = rank( M ) = rank( M ) − |B \ S * |.Rearranging the expression for rank(B ) in terms of rank we get: rank((B \ S * ) ∪ B ) = rank(B ) + rank(B \ S * ) = rank( M ) − |B \ S * | + |B \ S * | = rank( M ) where the second equation holds because B is a basis of M .Thus (B \ S * ) ∪ B is a basis of M , and we have Claim 15.The instances (M, ω, k, d) and ( M , ω, k, d) of Weighted Diverse Bases are equivalent.Recall the sets L = B ⊆ S * and L * = (S * \ L) from the construction.(L, L * ) is thus a partition of E( M ) = S * .From the construction we get L = B ⊆ B and L * ⊆ B. Now since rank(B) ≤ d 2 k and corank(B) ≤ d 2 k in M , we have that for every basis B of M , |B ∩ L| ≤ d 2 k and |L * \ B | ≤ d 2 k hold.This completes the description of the algorithm that returns the instance ( M , ω, k, d) and the partition (L, L * ) of E( M ).Since |L| ≤ d and |L * | ≤ d we have that |E( M )| ≤ 2 d It is straightforward to verify that given an independence oracle for M we can construct the following in polynomial time: (i) the set E( M ), (ii) an independence oracle for M that in time polynomial in |E(M )| answers queries for M , and (iii) the sets L and L * .To see this, note that A

Theorem 2 . 2 2 k 3 .
Weighted Diverse Bases can be solved in 2 O(dk 2 (log k+log d)) • |E(M )| O(1) time.Proof.Let (M, ω, k, d) be an instance of Weighted Diverse Bases.We run the algorithm from Lemma 11.If the algorithm solves the problem, then we are done.Otherwise, the algorithm outputs an equivalent instance ( M , ω, k, d) of Weighted Diverse Bases such that E( M ) ⊆ E(M ) and |E( M )| ≤ 2 d Moreover, the algorithm computes the partition (L, L * ) of E( M ) with the property that for every basis B of M , |B ∩ L| ≤ d 2 k and |L * \ B| ≤ d 2 k.Then we check all possible k-tuples of bases by brute force and verify whether there are k bases forming a solution.By the properties of L and L * , M has (d 2 k 3 ) O(dk) distinct bases.Therefore, we check at most (d 2 k 3 ) O(dk 2 ) k-tuples of bases.We conclude that this checking can be done in 2 O(dk 2 (log k+log d)) • |E(M )| O(1) time, and the claim follows.
Moreover any -cycle in σ corresponds to a cycle in G and any 2-cycle in σ corresponds to an edge in G, where the vertices covered in the cycle are the vertices present the cycle of the permutation.That is, for each

Claim 27 .
Let Q 1 and Q 2 be two collections of alternating cycles in G (i.e., the edges in Q i are alternating between M and E(G) \ M for each i ∈ {1, 2}) such that following hold:|E(Q 1 )| = |C 1 |, |E(Q 2 )| = |C 2 |, the edges in E(Q 1 ) uses distinct colors from C 1 , and the edges in E(Q 2 ) uses distinct colors from C 2 .Let P 1 = E(Q 1 ) M and P 2 = E(Q 2 ) M .Then, P 1 and P 2 are perfect matchings and |P 1 P 2 | ≥ d.

P 2 .
Since |E(Q 1 )| = |C 1 |, |E(Q 2 )| = |C 2 |, the edges in E(Q 1 ) uses distinct colors from C 1 , and the edges in E(Q 2 ) uses distinct colors from C 2 , we have that|E(Q 1 ) E(Q 2 )| ≥ |C 1 C 2 | ≥ d.Therefore, |P 1 P 2 | ≥ |E(Q 1 ) E(Q 2 )| ≥ d.Thus, to prove the lemma, it is enough to find a collectionQ i of alternating cycles such that |E(Q i )| = |C i |, the edges in E(Q i ) uses distinct colors from C i , for each i ∈ [r].That is, our algorithm guesses C 1 , . . .C r and computes Q 1 , . . ., Q r .The cost of guessing C 1 , . . ., C r is 2 r 2 s .Now, given C i , to compute Q i with desired property (|E(Q i )| = |C i |, the edges in E(Q i ) are colored with distinct colors from C i ),we design a simple dynamic programming (DP) algorithm.We give a brief outline of this algorithm below.For each subset L ⊆ C i and pair of vertices u, v we have table entries D[L, u, v] and D[L, ⊥, ⊥] which stores the following.If there is a collection Q of alternating cycles and an alternating path with u and v as endpoints such that |E(Q)| = |L| and the edges in E(Q) are colored with distinct colors from L, then we store one such collection in D[L, u, v].Otherwise, we store ⊥ in D[L, u, v].If there is a collection Q of alternating cycles such that |E(Q )| = |L| and the edges in E(Q ) are colored with distinct colors from L, then we store one such collection in D[L, ⊥, ⊥].Otherwise, we store ⊥ in D[L, ⊥, ⊥].We compute the DP table entries in the increasing order of the size of L. The base case is when L = ∅.That is, D[∅, ⊥, ⊥] = ∅ and D[∅, u, v] = ⊥ for any two vertices u and v. Now, for any ∅ = L ⊆ C i , and two distinct vertices u, v ∈ V (G), we compute D[L, u, v] and D[L, ⊥, ⊥] as follows.If there is an edge

−rs . If no such perfect matchings exist, then the algorithm outputs No.
d 2 − 1 holds.Let B be an arbitrary basis of M , and let B = (E(M ) \ B).If rank(B) ≥ k d 2 then there exists an independent set Y ⊆ B of size at least k d 2 .But Y is also a coindependent set of size at least k d 2 , which contradicts our assumption.Thus we get that rank(B) ≤ k d we get that every coindependent set contained in the set B has size at most k d 2 − 1.And since L * is a disjoint union of such coindependent sets we get that|L * | = |S * ∩ B| ≤ (k d 2 − 1) ≤ d , we get that if ( M * , ω, k, d) is a yes-instance of Weighted Diverse Bases, then there is a solution, that is, a family of bases B * 1 , . . ., B * k of M * such that ω(B * for every i ∈ {1, . . ., k}.In terms of M , the same property can be stated as follows. * i B * j ) ≥ d holds for all distinct i, j ∈ {1, . . ., k}, with the property that B * i ⊆ S * which are equal to e∈F \F x e • Π y∈L(e) y In other words if F is a perfect matching then Π e∈F x e • Π y∈L(e) y 2 is a unique term in (2), and if F is has cycle then the terms corresponding to F will cancel each other, because the characteristic of the F 2 [X ∪ Y ] is 2. Therefore, for any perfect matching M , Π e∈M x 2 e Π y∈L(e) y 2 is a monomial in det(A ).
2+ e∈F Π e∈F x e • Π y∈L(e) y (which we call the terms corresponding to F ).