How can I plot a multilayer graph (2 layer) starting from adjacency matrices?
Mostrar comentarios más antiguos
I need to plot a multilayer graph starting from adjacency matrices, like the one shown in the figure.

I have 3 adjacency matrices:
- A_gas (7x7 double): graph with nodes in red;
- A_power (24x24 double): graph with nodes in blue;
- A_interlayer (7x24 double): represents the connections between nodes in red and those in blue.
1 comentario
maybe something like this?
s1 = [ 3 3 1 4 10 8 4 5 6 8];
t1 = [6 10 10 10 11 11 8 8 11 9];
s2 = [1 1 1 1 1 2 2 7 7 9];
t2 = [2 3 4 5 7 6 7 5 9 6 ];
G1 = digraph(s1, t1);
G2 = digraph(s2, t2);
hold on
ax1 = plot(G1);
ax2 = plot(G2);
Respuesta aceptada
Más respuestas (1)
Vanshika Vaishnav
el 11 de Abr. de 2023
0 votos
You can represent the graph with this adjacency matrix:
0 1 2
1 0 3
2 3 0
To construct the graph in MATLAB, input:
A = [0 1 2; 1 0 3; 2 3 0];
node_names = {'A','B','C'};
G = graph(A,node_names)
G =
graph with properties:
Edges: [3×2 table]
Nodes: [3×1 table]
You can plot the directed graph as described in the following documentation in "Creating Graphs">>"Adjacency Matrix".
Also, you can code this way:
s1 = [ 3 3 1 4 10 8 4 5 6 8];
t1 = [6 10 10 10 11 11 8 8 11 9];
s2 = [1 1 1 1 1 2 2 7 7 9];
t2 = [2 3 4 5 7 6 7 5 9 6 ];
G1 = digraph(s1, t1);
G2 = digraph(s2, t2);
hold on
ax1 = plot(G1);
ax2 = plot(G2);
for more information refer this below documentation:
Categorías
Más información sobre Graph and Network Algorithms en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

