Along with the example I gave using graphAM, you might also want to look at the help page for the distGraph class which may be more directly what you want: library("graph") class ? distGraph