samedi 17 octobre 2020

How do I generate Matrix with sum of every individual row and column being zero

I need to generate a matrix where the diagonal are zeroes and every column and row has a sum of zero.

For example first row 0, 4, -2, -1, 1 = sum is 0
or the first column 0, -4, 2, 1, 1 = sum is 0

This works for every column and row of course

0, 4, -2, -1, -1
-4, 0, 3, 3, -2
2, -3, 0, -1, 2 
1, -3, 1, 0, 1 
1, 2, -2, -1, 0

The diagonal is always filled with zeroes. Im trying to create a weighted graph that is balanced for every connection it does.




Aucun commentaire:

Enregistrer un commentaire