function ib_bound=ib_longest(L1)
N = size(L1, 1);
L = ones(N, N, N);
L(:, :, 1) = L1;

disp_string = sprintf('L%d=', 1);
disp(disp_string);
disp(L(:, :, 1));

for n = 2:1:N
    for j = 1:1:N
        for i = 1:1:N
            max_vec = [-1]; % potential maximum paths     
            for k = 1:1:N
                if ((L(i, k, 1) ~= -1) && (L(k, j, n-1) ~= -1))
                    path_weight = L(i, k, 1) + L(k, j, n-1);
                    max_vec = [max_vec, path_weight];
                end
            end
        
            L(i, j, n) = max(max_vec);
            clear max_vec;
        end
    end

    disp_string = sprintf('L%d=', n);
    disp(disp_string);
    disp(L(:, :, n));

end

bound_vec=[]; %potential iteration bound
for n = 1:1:N;
    for i = 1:1:N;
        if (L(i, i, n) ~= -1)
            bound_vec = [bound_vec, L(i, i, n) / n];
        end
    end
end

ib_bound = max(bound_vec);

return



