How can I plot a multilayer graph (2 layer) starting from adjacency matrices?
古いコメントを表示
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 件のコメント
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);
採用された回答
その他の回答 (1 件)
Vanshika Vaishnav
2023 年 4 月 11 日
0 投票
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:
カテゴリ
ヘルプ センター および File Exchange で Graph and Network Algorithms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

