How to check if there is an edge between two nodes in an undirected graph?

14 ビュー (過去 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!


Christine Tobler
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 件のコメント
Waseem AL Aqqad
Waseem AL Aqqad 2022 年 5 月 23 日
Thank you so much, Christine!


その他の回答 (1 件)

Pratibha Chaudhary
Pratibha Chaudhary 2022 年 11 月 9 日
findedge(g, node1, node2).


Find more on Graph and Network Algorithms in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by