Azzera filtri
Azzera filtri

Duplicate edges not supported after using unique

2 visualizzazioni (ultimi 30 giorni)
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 Commenti
Guillaume
Guillaume il 15 Ott 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 il 16 Ott 2018
Okay Guillaume, thanks you very much.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Graph and Network Algorithms in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by