Path between 2 nodes in a graph
古いコメントを表示
How to check if a path exists between two nodes in a graph?
採用された回答
その他の回答 (1 件)
Christine Tobler
2020 年 9 月 28 日
Compute a path between the nodes, then check if the result is empty (this is returned by shortestpath if no path exists):
path = shortestpath(G, firstNode, secondNode)
pathExists = ~isempty(path);
2 件のコメント
Hari
2020 年 10 月 4 日
Bruno Luong
2020 年 10 月 4 日
Read Michael's answer that suggests using concomp
カテゴリ
ヘルプ センター および 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!
