How can I create a matrix from the nodes-edges-graph?

8 次查看(过去 30 天)
I am doing my master thesis and I need to create a design-structure matrix automatically. I want to have this function: I define the interaction of the features first and then automatically create the graph(see below) and the matrix. How can I realize this function? Thx.
PS: DSM is like N-Square matrix, which show the interaction of the features. It's simpler because it's binary. The elements are either 0 or 1, means relevant or irrelevant.

回答(1 个)

Stephen Jue
Stephen Jue 2017-6-21
You can create a design-structure matrix from a graph object by using the adjacency method.
Once the matrix is created, heatmap is a good way to visualize it.
This code demonstrates how to create an adjacency matrix (or DSM) from a graph, then plot a heatmap of the matrix:
s = [1 1 1 2 2 3];
t = [2 3 4 5 6 7];
G = digraph(s,t)
figure
subplot(1,2,1)
plot(G)
A = adjacency(G);
subplot(1,2,2)
heatmap(A)
  1 个评论
Jay Vaidya
Jay Vaidya 2020-1-1
Dear Mr Stephen,
I am having the similar problem, https://www.mathworks.com/matlabcentral/answers/498570-how-to-convert-the-graph-below-in-to-heatmap here. It would be really great if you could help me with this.
I have been putting questions for this as if you see this thread https://www.mathworks.com/matlabcentral/answers/498447-how-can-i-convert-2-column-matrix-to-a-cell-array This thread was made for the same question. My ultimate goal is to transform,
matrix->graph->adjacency matrix-> heatmap. My ultimate goal is to plot a heatmap from the input matrix. The input matrix is fig a (below). The goal is heatmap which I guess will need fig c. When I use a couple of solutions provided, I dont find the SizeX and SizeY in fig b and fig c to be matching. But I need it to be matched so that I can just represent the graph in form of a heatmap. Thanks in advance. Happy new year 2020. 7.JPG

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 数据分布图 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!