Path between 2 nodes in a graph
Afficher commentaires plus anciens
How to check if a path exists between two nodes in a graph?
Réponse acceptée
Plus de réponses (1)
Christine Tobler
le 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 commentaires
Hari
le 4 Oct 2020
Bruno Luong
le 4 Oct 2020
Read Michael's answer that suggests using concomp
Catégories
En savoir plus sur Graph and Network Algorithms dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
