MATLAB: MATLAB: How to Generate Square Matrices with these properties

adjacencyadjacency matrixarraydiagonalmathematicsMATLABmatrixmatrix creation

Hello All, I was wondering how I would create a systematic Matrix Generator which goes element by element in order to generate All Graphs of Node Size 3 which have these properties:
1) All entries are a 0 or 1
2) Each Element where m = n (diagonal) must equal 0
3) There must exist at least a single "1" in each row and column
4) Entries across the diagonal must be opposite:
For example, If A(1,2) = 1 then A(2,1) must Equal 0
The generator must be able to store all of its generated graphs for later use and analysis

Best Answer

N = 3;
M = N * (N-1) / 2;
numgraph = 2^M;
choices = dec2bin(0:numgraph-1, M) - '0';
graphs = cell(numgraph,1);
for K = 1 : numgraph
sq = squareform(choices(K,:));
sq = tril(1-sq) + triu(sq)
graphs{K} = digraph(sq);
end