genrgg_long.m 525 Bytes
Newer Older
mrebollo committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
function [rgg] = genrgg_long(n, coor, dist)
%GENRGG	Generates a Random Geometric Graph
%	A rangom reometric graph is a random graph in the unit square [0,1]
%	where nodes are linked when they are closer that a minimum distance dist
%   One lomg-range link added with prob inverse to the distance
    [A, dmat] = genrgg(n, coor, dist);
    % add long-range links as in kleinberg model
    for i = 1:n
        j = randi(n);
        if(dmat(i,j) < rand())
            A(i,j) = 1;
            A(j,i) = 1;
        end
    end
end