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

23 visualizzazioni (ultimi 30 giorni)
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!

Risposta accettata

Christine Tobler
Christine Tobler il 20 Mag 2022
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.

Più risposte (1)

Pratibha Chaudhary
Pratibha Chaudhary il 9 Nov 2022
findedge(g, node1, node2).

Categorie

Scopri di più su Graph and Network Algorithms in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by