Path between 2 nodes in a graph
Ältere Kommentare anzeigen
How to check if a path exists between two nodes in a graph?
Akzeptierte Antwort
Weitere Antworten (1)
Christine Tobler
am 28 Sep. 2020
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 Kommentare
Hari
am 4 Okt. 2020
Bruno Luong
am 4 Okt. 2020
Read Michael's answer that suggests using concomp
Kategorien
Mehr zu Graph and Network Algorithms finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
