Rearrange the rows in the matrix to make sure that each diagonal value is nonzero?

I have a 12x12 matrix with diagonal values ​​that vary from zero to zero, I wonder if there is an algorithm to replace all the rows in the matrix to make sure there is no non-zero value. My matrix C must not have a nonzero value in C (i, i). Thoughts?

Example: I have a 5x5 matrix

3 4 5 0 6
1 0 4 3 0
0 5 1 0 3
0 1 0 2 0 
2 0 5 0 0

How to make sure that there are no nonzero diagonal elements?

+4
source share
1 answer
  • Build a bipartite graph.
    • Create a set of nodes, one for each row index, on the left.
    • Create a set of nodes, one for each column index, on the right.
  • A (i, j):
    • A (i, j) , node node j.
  • . N , . Edge (i, j) , j.

. : http://en.wikipedia.org/wiki/Bipartite_matching#In_unweighted_bipartite_graphs

+2

Source: https://habr.com/ru/post/1530145/


All Articles