How to merge nodes in graph plot for R2020b?

7 ビュー (過去 30 日間)
Jessica Jiaying
Jessica Jiaying 2021 年 3 月 6 日
コメント済み: Jessica Jiaying 2021 年 3 月 13 日
How should I merge nodes in graph plot for R2020b?
I have the following current source_nodes, target_nodes and distances. However, I am looking to merge some of the nodes depending on distance (like for example, 0.25 and below). I have tried to search online and came across nodejoin but it doesn't seem to work for graph plots with nodes and edges.
source_nodes = [1, 2, 3, 4]
target_nodes = [5, 6, 7, 8]
distances = [0.25, 1.00, 2.00, 0.25]
If possible, I would like to merge Nodes 1 and 5 and Nodes 4 and 8 respectively with new label names made from combining their original node labels like '15' and '48'. I need to keep the connectivity to the other nodes the same.

採用された回答

Shiva Kalyan Diwakaruni
Shiva Kalyan Diwakaruni 2021 年 3 月 11 日
Hi,
digraph objects represent directed graphs, which have directional edges connecting the nodes. After you create a digraph object, you can try using the object functions to perform queries against the object.
example :-
e = G.Edges
G = addedge(G,2,3)
G = addnode(G,4)
You can follow the below link showing the example of creating a graph with source ,target nodes and edge weights.
You can also modify the label names by giving the names as one of the parameter to digraph function
hope it helps,
thanks.
  1 件のコメント
Jessica Jiaying
Jessica Jiaying 2021 年 3 月 13 日
Thank you very much! I tried it and it worked :)

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by