function[A,dmat]=genrgg(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 distdmat=squareform(pdist(coor));%matrix with distances (think about handle it in a vector)ifnargin<3dist=min(max(dmat));end[row,col]=find(dmat<dist);A=spones(sparse([row;col],[col;row],1,n,n));A(1:n+1:n*n)=0;end