MATLAB
Posts  1 - 1  of  1
HC1234
Hi,

I am trying to output an adjacency matrix for a given number of nodes(n) with K connectivity(incoming links) with no self and double connections.My code goes like this:

n = input('enter the value of n:');
k = input('enter the value of k:');
if nn = input('enter the value of n:');
k = input('enter the value of k:');
else
% A= zeros(n);
for i=1:1:n
for j=1:1:n

A = randint(n,n,[0,1]);

if i==j
A(i,j) = 0;
disp(A);
end
end
end
end

How do i do this in matlab for given n and K values to output an adjacency matrix?Any ideas are appreciated.I am new to matlab and i could try as far as i can.

Thanks!!
Save
Cancel
Reply
 
x
OK