# How to draw a network of nodes in circular formation with links between nodes in MATLAB?

1 visualizzazione (ultimi 30 giorni)
Haya Ali il 25 Mag 2023
Commentato: Steven Lord il 25 Mag 2023
I have a connectivity matrix
and I want a figure like this for my matrix.
A= [-1 -1 0 0 0 0 0 1 0 1 0 0 -1 1 1 -1 1 0 -1 1 -1 1 0;
1 -1 0 0 -1 0 -1 -1 0 0 -1 1 0 0 0 -1 1 -1 0 -1 -1 0 1;
0 1 -1 0 0 0 -1 1 -1 -1 -1 1 0 0 0 0 -1 0 0 -1 1 0 0;
1 0 0 1 0 0 -1 -1 0 0 0 1 -1 0 0 -1 1 -1 0 -1 -1 1 1;
-1 0 -1 0 1 0 0 1 0 1 0 -1 -1 1 1 0 0 0 0 1 1 0 0;
0 0 -1 0 0 0 1 0 0 1 0 0 1 -1 0 1 0 -1 1 1 -1 1 -1;
1 0 0 0 -1 0 0 1 0 1 -1 -1 -1 0 0 -1 -1 -1 0 0 -1 1 0;
1 0 1 0 1 0 0 1 0 0 1 1 -1 1 0 -1 0 0 0 0 -1 -1 0;
0 0 -1 -1 0 0 0 -1 0 -1 0 1 1 0 1 -1 1 -1 -1 -1 -1 0 0;
0 -1 -1 -1 1 0 0 -1 0 0 0 0 1 1 0 -1 1 0 0 -1 -1 0 1;
0 0 1 0 -1 0 -1 0 0 1 -1 -1 0 0 -1 0 -1 0 -1 1 1 1 1;
-1 0 0 1 1 0 -1 -1 0 -1 -1 1 -1 0 -1 0 0 1 0 1 1 0 1;
0 -1 -1 0 1 0 -1 -1 0 -1 0 0 -1 0 0 -1 1 0 0 1 0 0 -1;
0 -1 0 -1 -1 0 0 -1 0 0 0 -1 1 1 0 0 1 0 0 -1 -1 0 0;
-1 0 -1 -1 1 0 0 1 0 1 0 -1 1 1 1 -1 0 0 -1 0 0 -1 -1;
-1 0 0 1 0 -1 -1 -1 0 -1 -1 1 -1 0 0 0 0 0 -1 1 1 1 1;
0 -1 -1 0 1 0 -1 -1 0 -1 0 0 1 0 0 1 0 0 0 1 1 1 -1;
1 1 -1 0 -1 0 -1 1 0 1 -1 -1 -1 0 1 0 -1 -1 0 0 1 0 -1;
0 -1 1 1 0 0 -1 -1 1 1 0 -1 -1 1 0 -1 1 0 -1 0 0 1 0;
0 -1 -1 0 1 0 0 1 0 1 0 0 -1 1 0 1 1 0 -1 0 -1 0 -1;
1 1 -1 1 -1 0 0 0 -1 1 0 0 -1 0 -1 -1 -1 0 1 1 1 1 0];
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Steven Lord il 25 Mag 2023
Use the Graph and Network Algorithms functionality included in MATLAB once you've corrected your adjacency matrix.
A= [-1 -1 0 0 0 0 0 1 0 1 0 0 -1 1 1 -1 1 0 -1 1 -1 1 0;
1 -1 0 0 -1 0 -1 -1 0 0 -1 1 0 0 0 -1 1 -1 0 -1 -1 0 1;
0 1 -1 0 0 0 -1 1 -1 -1 -1 1 0 0 0 0 -1 0 0 -1 1 0 0;
1 0 0 1 0 0 -1 -1 0 0 0 1 -1 0 0 -1 1 -1 0 -1 -1 1 1;
-1 0 -1 0 1 0 0 1 0 1 0 -1 -1 1 1 0 0 0 0 1 1 0 0;
0 0 -1 0 0 0 1 0 0 1 0 0 1 -1 0 1 0 -1 1 1 -1 1 -1;
1 0 0 0 -1 0 0 1 0 1 -1 -1 -1 0 0 -1 -1 -1 0 0 -1 1 0;
1 0 1 0 1 0 0 1 0 0 1 1 -1 1 0 -1 0 0 0 0 -1 -1 0;
0 0 -1 -1 0 0 0 -1 0 -1 0 1 1 0 1 -1 1 -1 -1 -1 -1 0 0;
0 -1 -1 -1 1 0 0 -1 0 0 0 0 1 1 0 -1 1 0 0 -1 -1 0 1;
0 0 1 0 -1 0 -1 0 0 1 -1 -1 0 0 -1 0 -1 0 -1 1 1 1 1;
-1 0 0 1 1 0 -1 -1 0 -1 -1 1 -1 0 -1 0 0 1 0 1 1 0 1;
0 -1 -1 0 1 0 -1 -1 0 -1 0 0 -1 0 0 -1 1 0 0 1 0 0 -1;
0 -1 0 -1 -1 0 0 -1 0 0 0 -1 1 1 0 0 1 0 0 -1 -1 0 0;
-1 0 -1 -1 1 0 0 1 0 1 0 -1 1 1 1 -1 0 0 -1 0 0 -1 -1;
-1 0 0 1 0 -1 -1 -1 0 -1 -1 1 -1 0 0 0 0 0 -1 1 1 1 1;
0 -1 -1 0 1 0 -1 -1 0 -1 0 0 1 0 0 1 0 0 0 1 1 1 -1;
1 1 -1 0 -1 0 -1 1 0 1 -1 -1 -1 0 1 0 -1 -1 0 0 1 0 -1;
0 -1 1 1 0 0 -1 -1 1 1 0 -1 -1 1 0 -1 1 0 -1 0 0 1 0;
0 -1 -1 0 1 0 0 1 0 1 0 0 -1 1 0 1 1 0 -1 0 -1 0 -1;
1 1 -1 1 -1 0 0 0 -1 1 0 0 -1 0 -1 -1 -1 0 1 1 1 1 0];
sz = size(A)
sz = 1×2
21 23
g = graph(A, 'upper');
Error using graph
##### 2 CommentiMostra NessunoNascondi Nessuno
Haya Ali il 25 Mag 2023
23 by 23
Steven Lord il 25 Mag 2023
A = rand(23, 23) < 0.25; % Random adjacency matrix with roughly 25% nonzeros
nnz(A)./numel(A)
ans = 0.2533
g = graph(A, 'upper');
plot(g)

Accedi per commentare.

### Categorie

Scopri di più su Networks in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by