Checking if 2 edges in a graph are connected

4 ビュー (過去 30 日間)
Hari
Hari 2021 年 5 月 14 日
編集済み: Stephan 2021 年 5 月 14 日
I have plotted an undirected network using graph function in matlab. How can I check if 2 nodes in the network are connected by an edge? I have tried using the 'is Connected' function but I guess it is not for networks as it is showing an error 'Check for missing argument or incorrect argument' data type in call to function 'isConnected'. Any help is appreciated

採用された回答

Stephan
Stephan 2021 年 5 月 14 日
編集済み: Stephan 2021 年 5 月 14 日
You could use the neighbors function, which gives a list of connected nodes for a given node. You could combine this with the ismember function to get a logical result it your both nodes are connected or not.
G = graph(bucky);
N = neighbors(G,10) % show neighbors of node 10
N = 3×1
6 9 12
check if 3 is a neighbor:
ismember(3, neighbors(G,10))
ans = logical
0
check if 12 is a neighbor:
ismember(12, neighbors(G,10))
ans = logical
1

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by