Convert weighted digraph to undirected

Is there any way of converting a weighted digraph to undirected?
eg. Node1-Node2-Weight A-B-1 B-A-1
Will become: A-B-2 ?

 採用された回答

Walter Roberson
Walter Roberson 2017 年 10 月 23 日

1 投票

Take the adjacency matrix of the weighted digraph and add it to its transpose; build an undirected graph from the result.

3 件のコメント

UQFG
UQFG 2017 年 10 月 24 日
If I use:
g=graph(adjacency(d)+transpose(adjacency(d)))
for d (digraph) with edge table like this: EndNodes--Weight
A B 1
C D 2
D C 1
E F 1
then I get the output of g edge table:
1 2 1
3 4 2
5 6 1
...which means that the C<->D weights are not adding properly for undirected.
ie. should be:
1 2 1
3 4 *3*
5 6 1
Walter Roberson
Walter Roberson 2017 年 10 月 24 日
https://www.mathworks.com/help/matlab/ref/graph.adjacency.html#buy61af shows how to reconstruct the weighted adjacency matrix.
UQFG
UQFG 2017 年 10 月 27 日
Thank you for that link!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGraph and Network Algorithms についてさらに検索

質問済み:

2017 年 10 月 23 日

コメント済み:

2017 年 10 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by