Plot directed graph from 2D matrix

2 ビュー (過去 30 日間)
lucksBi
lucksBi 2017 年 5 月 23 日
コメント済み: lucksBi 2017 年 5 月 23 日
Hi i want to know that how to plot a directed tree from a given 2d matrix. for example i have data in this from:
and i want to plot directed tree like this:
In which 2 4 5 6 are nodes (keeping 2 as root) and there will be an edge if value is other than zero. e.g. (2,4)=1
Thanks in advance

採用された回答

Walter Roberson
Walter Roberson 2017 年 5 月 23 日
See graph() to construct a graph object, and then plot() the graph object to draw it.
  3 件のコメント
Walter Roberson
Walter Roberson 2017 年 5 月 23 日
adj = [0 1 0 0;
0 0 0 1;
1 1 1 0;
0 0 1 1];
G = digraph(adj, {'2', '4', '5', '6'}, 'OmitSelfLoops');
plot(G)
lucksBi
lucksBi 2017 年 5 月 23 日
Thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by