필터 지우기
필터 지우기

Duplicate edges not supported after using unique

조회 수: 2 (최근 30일)
Isaac Osei Agyemang
Isaac Osei Agyemang 2018년 10월 15일
댓글: Isaac Osei Agyemang 2018년 10월 16일
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
Guillaume
Guillaume 2018년 10월 15일
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 2018년 10월 16일
Okay Guillaume, thanks you very much.

댓글을 달려면 로그인하십시오.

답변 (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