Borrar filtros
Borrar filtros

Duplicate edges not supported after using unique

2 visualizaciones (últimos 30 días)
Isaac Osei Agyemang
Isaac Osei Agyemang el 15 de Oct. de 2018
Comentada: Isaac Osei Agyemang el 16 de Oct. de 2018
Hello community, I'm comparing two graphs, I'm able to plot the first graph fine and afterwards i sort the data in the table to replot the secod graph. I use unique to eliminate any duplicate rows in order not for the error duplicate edges not supported to show up but for some reasons it still throw the error duplicate edges not supported. Code is below:
a = 1:2637;
NewEdge(a,1) = sort(NewEdge(a,1));
b = 1:2637;
NewEdge(b,2) = sort(NewEdge(b,2),'descend');
%NewEdge(:,1:2) = sort(NewEdge(:,1:2));
NewEdge = unique(NewEdge(:,1:2),'rows'); %eliminate duplicates
GG = graph(NewEdge(:,1), NewEdge(:,2)); % create a graph from A
d = degree(GG);
notConnected = find(d < 2); % weakly connected nodes
d(notConnected) = []; % drop them from deg
GG = rmnode(GG, notConnected); % drop them from graph
figure % visualize the graph
plot(GG);
title('Power Grid, After movement')
  2 comentarios
Guillaume
Guillaume el 15 de Oct. de 2018
Which function throws your duplicate edge not supported error? plot has no problem plotting graphs with duplicate edges.
Note that if you want to remove duplicate edges in a graph, the simplest way to do that is:
%remove duplicate edges from graph g
g = graph(unique(g.Edges));
Isaac Osei Agyemang
Isaac Osei Agyemang el 16 de Oct. de 2018
Okay Guillaume, thanks you very much.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by