Path between 2 nodes in a graph
Mostrar comentarios más antiguos
How to check if a path exists between two nodes in a graph?
Respuesta aceptada
Más respuestas (1)
Christine Tobler
el 28 de Sept. de 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 comentarios
Hari
el 4 de Oct. de 2020
Bruno Luong
el 4 de Oct. de 2020
Read Michael's answer that suggests using concomp
Categorías
Más información sobre Graph and Network Algorithms en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
