'How to delete duplicate (isomorphism) in a cell array of graph adjacency matrix?

I have a cell array of adjacency matrices of graphs. Some of them are isomorphic, I want to delete them so that obtain a cell array of non-isomorphic graphs. The code for checking graph isomorphic based on adjacency matrix is here.

adjs =

  1×13 cell array

  Columns 1 through 3

    {4×4 double}    {4×4 double}    {4×4 double}

  Columns 4 through 6

    {4×4 double}    {4×4 double}    {4×4 double}

  Columns 7 through 9

    {4×4 double}    {4×4 double}    {4×4 double}

  Columns 10 through 12

    {4×4 double}    {4×4 double}    {4×4 double}

  Column 13

    {4×4 double}

In order to do that, I tried the following code but it gives me the error

Index exceeds the number of array elements. Index must not
exceed 11.

Error in circulantg (line 42)
            s2=adjs(j);

Here is my code

addpath 'path of graph_isomorphism'
addpath libsvm

n=4;
vertices=1:n;
adjs={};

for k = 1:length(vertices) 
    subsets = nchoosek(vertices,k); 
    sizes = size(subsets);
    for j = 1:sizes(1) 
        sizes(1);
        length(vertices);
        l = subsets(j,:); 
        A = circulant(n,l);
        adjs{end+1}=A;
    end
end

dim =  size(adjs);
num_graphs = dim(2);
m = num_graphs
for i = 1:m 
    i
    for j = 2:m 
        if i~=j
            s1=adjs(i);
            s2=adjs(j);
            if graph_isomorphism(s1{1,1},s2{1,1})==1 
                adjs(j)=[]; 
                dim =  size(adjs);
                m = dim(2)
            end
        end
    end
end


function A = circulant(n,l)
%input: n denotes size of graph, l is a list of integers
%output: the generated circulant graph
    g=graph;
    g = addnode(g,n);
    for i = 1:numnodes(g)
        for j = 1:length(l)
            i = int64(i);
            j = l(j);
            if mod(i+j,n)==0
                g = addedge(g,i,n);
            else
                g = addedge(g,i,mod(i+j,n));
            end
    
            if mod(i-j,n)==0
                g = addedge(g,i,n);
            else
                g = addedge(g,i,mod(i-j,n));
            end
    
         end
    end
    g = graph(unique(g.Edges)); % edges duplicate in g, thus delete them.
    g = rmedge(g, 1:numnodes(g), 1:numnodes(g));
    A = adjacency(g);
    class(A);
end

Could anyone help?

Thanks a lot!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source