Home > matgraph > @graph > sprandom.m

sprandom

PURPOSE ^

sprandom(g,n,p) --- create a sparse random graph

SYNOPSIS ^

function sprandom(g,n,p)

DESCRIPTION ^

 sprandom(g,n,p) --- create a sparse random graph
 This overwrites g with a sparse random graph on n vertices with edge
 probability p.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function sprandom(g,n,p)
0002 % sprandom(g,n,p) --- create a sparse random graph
0003 % This overwrites g with a sparse random graph on n vertices with edge
0004 % probability p.
0005 
0006 global GRAPH_MAGIC
0007 
0008 A = triu(sprand(n,n,p));
0009 A = A + A';
0010 for k=1:n
0011     A(k,k)=0;
0012 end
0013 A = logical(A>0);
0014 GRAPH_MAGIC.graphs{g.idx}.array = A;
0015 rmxy(g);

Generated on Thu 13-Mar-2008 14:23:52 by m2html © 2003