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

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 Exchange에서 Undirected Graphs에 대해 자세히 알아보기

질문:

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