Checking if 2 edges in a graph are connected
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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
check if 3 is a neighbor:
ismember(3, neighbors(G,10))
check if 12 is a neighbor:
ismember(12, neighbors(G,10))
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graph and Network Algorithms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!