How can the edges on the shortestpath be determined?
2 ビュー (過去 30 日間)
古いコメントを表示
After using shortestpath (Dijkstra algorithm) on directed and weighted graph, Matlab gives the node sequence on the shortest path.
How can I write the edges on the shortest path?
Thanks
CO
0 件のコメント
採用された回答
Chunru
2022 年 6 月 27 日
編集済み: Chunru
2022 年 6 月 28 日
s = [1 1 2 3 3 4 4 6 6 7 8 7 5];
t = [2 3 4 4 5 5 6 1 8 1 3 2 8];
G = digraph(s,t);
plt = plot(G)
[P, d, edgepath] = shortestpath(G,7,8)
E = G.Edges(edgepath, :)
highlight(plt, 'Edges', edgepath)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Graph and Network Algorithms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!