function result = attemptconnection(s_new,STATE_STORE,Edge_start, Edge_end, N_grid)
result = -1;
for n=1:size(STATE_STORE,1)%Check if the new node is already discovered and connected
    if s_new' == STATE_STORE(n,:)
        result = 0;
        break
    end
end
if result == -1%The node is not previously discovered
    for n=1:size(Edge_start,2)
        if nodetovector(Edge_start(1,n),N_grid)==s_new
            for k=1:size(STATE_STORE,1)
                if nodetovector(Edge_end(1,n),N_grid)==(STATE_STORE(k,:))'
                    result = 1;
                    break;
                end
            end
        end
    end
    if result == -1
        for n=1:size(Edge_end,2)
            if nodetovector(Edge_end(1,n),N_grid)==s_new
                for k=1:size(STATE_STORE,1)
                    if nodetovector(Edge_start(1,n),N_grid)==(STATE_STORE(k,:))'
                        result = 1;
                        break;
                    end
                end
            end
        end
    end
end
        




end