필터 지우기
필터 지우기

how to remove duplicate edges like A-B, B-A are showing same.

조회 수: 1 (최근 30일)
TR RAO
TR RAO 2018년 2월 13일
답변: KSSV 2018년 2월 13일
fileID = fopen('C:\Users\TR RAO\Desktop\rao.txt','r');
C = textscan(fileID, '%s %s');
fclose(fileID);
d1=cellstr(C{1,1});d2=cellstr(C{1,2});
G=graph(d1,d2);
A=adjacency(G)
The above program is not allowing duplicates. Kindly suggest me solution
Input:
1 2
1 3
1 4
2 1
4 1
2 3

답변 (1개)

KSSV
KSSV 2018년 2월 13일
A = [1 2
1 3
1 4
2 1
4 1
2 3] ;
% Get distance of th epoints from origin
data = repmat([0 0],[length(A),1])-A ;
dist = sqrt(data(:,1).^2+data(:,2).^2);
[c,ia,ib] = unique(dist) ;
iwant = A(ia,:)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by