How to highlight isolated nodes in a graph?

1 visualización (últimos 30 días)
Asaf McRock
Asaf McRock el 22 de Feb. de 2021
Editada: Asaf McRock el 24 de Feb. de 2021
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!
  1 comentario
Asaf McRock
Asaf McRock el 22 de Feb. de 2021
Does distances measure the distance between the node and itself?

Iniciar sesión para comentar.

Respuesta aceptada

Steven Lord
Steven Lord el 22 de Feb. de 2021
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 comentario
Asaf McRock
Asaf McRock el 22 de Feb. de 2021
Editada: Asaf McRock el 24 de Feb. de 2021
Thank you very much, Mr. Steven Lord. This is amazing, I don't know why I was complicating it.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graph and Network Algorithms en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by