How get the Adjacency matrix from complete graph

조회 수: 6 (최근 30일)
Konstantinos koutsikakis
Konstantinos koutsikakis 2020년 10월 20일
댓글: Konstantinos koutsikakis 2020년 10월 20일
Hi I need get the Adjacency matrix from this code
% Complete Graph
% N no Nudes
% E = edges
n = input('Give Number Nudes: ');
E = (n*(n-1)/2);
theta = linspace(0,2*pi,n+1).';
theta(end)=[]; % 0 = 2pi so...
r = n;
cor = [r*cos(theta) r*sin(theta)]; % x coordinates of points
axes('nextplot','add')
while size(cor,1) > 1
cor_pt = repmat(cor(1,:),size(cor,1)-1,1); % point being connected to others
cor(1,:) = [];
for i = 1:size(cor_pt,1)
line([cor_pt(i,1),cor(i,1)],[cor_pt(i,2),cor(i,2)],'marker','.','markersize',30)
end
end

채택된 답변

Stephan
Stephan 2020년 10월 20일
편집: Stephan 2020년 10월 20일
Its trivial:
A = ones(n) - diag(diag(ones(n)))
or, more easy
A = ones(n) - eye(n)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by