How to check if there is an edge between two nodes in an undirected graph?
13 次查看(过去 30 天)
显示 更早的评论
How can I check if any two nodes in an undirected graph are connected via an edge or not, please? in other words, Are they neighbors or not? Thanks!
0 个评论
采纳的回答
Christine Tobler
2022-5-20
Call findedge(g, node1, node2). If there is no edge connecting these nodes, the output is zero. Otherwise, the output is the index into the Edges table of the connecting edge.
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Undirected Graphs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!