Let us be given a n &#x00D7;<!-- × --> n matrix containing only zeros and ones.Now, the

arridsd9

arridsd9

Answered question

2022-06-28

Let us be given a n × n matrix containing only zeros and ones.Now, the goal is to remove some 'ones' from the matrix (i.e. replace them with zeros) so that in each row and each column there is at most one 'one'. Of course, it is preferable that we leave as much 'ones' as it is possible (maximum is obviously n).
Now, let us define the following algorithm: if there is a 'one' which is all alone in a column or a row, leave it there, and replace all 'ones' in its column and row with zeros. We repeat the process as long as there are single 'ones' in rows or columns. If there are no single 'ones' left, we take the first row or column (first is counted from up (for rows) and from left (for columns)) containing two 'ones' (if there are no pairs, we go for the first triplet and so on). In that pair (or triplet, or ...) we leave the first 'one' intact (first is counted from the left for elements of row, from the top for elements of a column) and change all other 'ones' in the row and column of that first 'one' into zeros. Now, we check are there now any single 'ones' as defined above - if yes, we repeat that part of the algorithm, if no, we look for the first pair, triplet, etc. The algorithm ends when all 'ones' are singles both in their column and row.
Does this algorithm always give the maximum covering, i.e. does it always terminate with maximal number of 'ones' in the final matrix? In other words, can there be a matrix with a possible exclusion of some ones such that it ends up with n ones using some other exclusion scheme, while ending up with less than n 'ones' using the algorithm described above?

Answer & Explanation

Josie123

Josie123

Beginner2022-06-29Added 16 answers

Yes. Consider a large square matrix with two large square blocks filled with ones and one empty row and one empty column. Delete one one from each of the blocks off the diagonal, and place a corresponding one in the empty row and column. You now have one row with two elements, the rest having many elements, and one column having only two elements, the rest having many. Your procedure will deal with the sparesely populated row and column first. Permute the rows and columns so that you procedure links the two choices with different blocks. Now the remainder of each block has one more row than it has columns or vice versa, as a perfect matching cannot exist. It is easy to see however that a perfect matching existed before your algorithm matched the sparse row and column.
gvaldytist

gvaldytist

Beginner2022-06-30Added 12 answers

Another way to express this problem is finding maximum partial matchings in a bipartite graph. (Just interpret the matrix an adjacency matrix for the graph). By a maximum partial matching I mean a maximal-sized set of edges no two having a vertex in common.
The reason for my scepticism is that if your algorithm worked, then it would give an algorithm for finding the solution in the situation of Hall's marriage theorem. Your algorithm is "monotone" in the sense that it adds edges but never removes them, but all the algorithms I have seen for Hall's theorem, one needs to remove edges in certain circumstances in the process.
For the problem is hand, an algorithm comes from any that solves the maximum flow problem in a network. Attach a source to each vertex on one side of the bipartition and a sink to each vertex on the other side. Give all edges unit capacity and find a maximum flow.

Do you have a similar question?

Recalculate according to your conditions!

Ask your question.
Get an expert answer.

Let our experts help you. Answer in as fast as 15 minutes.

Didn't find what you were looking for?