How to highlight isolated nodes in a graph?

1 次查看(过去 30 天)
Hello, how can I highlight isolated nodes in a graph?
I have tried the following but didn't work:
d=distances(G,(1:N)); % N is the no. of nodes
idx= ismember(d,inf(1,length(d)), 'rows');
H=plot(G,'XData',x,'YData',y);
highlight(H,idx)
Thanks!

采纳的回答

Steven Lord
Steven Lord 2021-2-22
You want to highlight those nodes that are not connected to any other?
G = graph(sprand(10, 10, 0.05), 'upper');
h = plot(G);
highlight(h, degree(G) == 0, 'NodeColor', 'r')
  1 个评论
Asaf McRock
Asaf McRock 2021-2-22
编辑:Asaf McRock 2021-2-24
Thank you very much, Mr. Steven Lord. This is amazing, I don't know why I was complicating it.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graph and Network Algorithms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by