How to create (x,y) matrix in complete graph in matlab

조회 수: 2 (최근 30일)
Konstantinos koutsikakis
Konstantinos koutsikakis 2020년 10월 15일
편집: Konstantinos koutsikakis 2020년 10월 15일
Hi I have write code for make complete graph with n vertices. and E= n*(n-1)/2. This generated graph has to display its adjacency connections in a 2xN matrix.
% Complete Graph
% N arithos komvon
% E = edges
close all
n = input ('Dose ton arithmo ton konvon: ');
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',20)
end
end

답변 (1개)

Steven Lord
Steven Lord 2020년 10월 15일
If this is not a homework assignment where you're expected to write the code to plot a graph yourself, just use the graph function included in MATLAB. You can call it with the adjacency matrix of your graph and then plot it.
  댓글 수: 2
Konstantinos koutsikakis
Konstantinos koutsikakis 2020년 10월 15일
I need write code beacause is for my school.
Konstantinos koutsikakis
Konstantinos koutsikakis 2020년 10월 15일
But I need convert adjacency matrix from complete graph to table (x,y)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by