I want to use MATLAB to create the adjacency matrix for the following undirected graph data in this link.
When I apply "graph" function, I get the error that the matrix has duplicate edges. When I investigated the uniqueness of rows, all the rows were unique. When I tried to find the rows which are mirrored of each other (because in undirected graph still they are considered as duplication), I did not find any mirrored row. So, I am asking this question in here and I highly appreciate it, if someone can help me to get the adjacency matrix for this particular data.
The matrix "data" which has two columns contains "From-To" information of nodes. So, I firstly used the following command to get the adjacency matrix:
% Create a graph object from the node numbers
G = graph (data (:,1), data (:,2));
% Find the adjacency matrix of the graph
A = adjacency (G);
Then, I get this error message in MATLAB:
Error using matlab.internal.graph.MLGraph
Duplicate edges not supported.
Error in matlab.internal.graph.constructFromEdgeList (line 125)
G = underlyingCtor(double(s), double(t), totalNodes);
Error in graph (line 287)
matlab.internal.graph.constructFromEdgeList(...
Then, I tried this to find the rows which are duplicated
[~, ia, ic] = unique (data,'rows');
% Find the indices of the duplicate rows of A
dupRows = setdiff (1:size (A,1), ia (accumarray (ic,1)<=1));
Then, I did not get any rows which are duplicated.
Then I tried the following code to find the rows which are mirrored of each other :
[~, mirror_idx] = ismember (data,fliplr (data),'rows');
data (mirror_idx,:) = [];
and it literally eliminated all the rows of the matrix "data", (i.e. data=[])