igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] How to a generate a random bipartite graph (one-to-many)?


From: Tamás Nepusz
Subject: Re: [igraph] How to a generate a random bipartite graph (one-to-many)?
Date: Wed, 23 May 2012 12:43:24 +0200

> So to have many-to-many edges (i.e., vertices from both A and B to be
> able to have multiple neighbors), what should I write?

Something like:

cbind(sample(1:n, num.edges, replace=T), n + sample(1:m, num.edges, replace=T))

where num.edges is the number of edges you would like to have. This *might* 
generate multiple edges, but a quick call to simplify() after the graph 
construction will get rid of those.

(Also, there was a mistake in my previous code sample; it should have been:

cbind(1:n, n + sample(1:m, num.edges, replace=T))
)

-- 
T.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]