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

1 Ansicht (letzte 30 Tage)
Konstantinos koutsikakis
Konstantinos koutsikakis am 15 Okt. 2020
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

Antworten (1)

Steven Lord
Steven Lord am 15 Okt. 2020
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 Kommentare
Konstantinos koutsikakis
Konstantinos koutsikakis am 15 Okt. 2020
I need write code beacause is for my school.
Konstantinos koutsikakis
Konstantinos koutsikakis am 15 Okt. 2020
But I need convert adjacency matrix from complete graph to table (x,y)

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by