Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Assuming the input consists of n, r, and the probabilities for edges within a community; and assuming that the probability of edges between vertices in different communities is 0, then here is a possible way to generate such a graph.

community_sizes = Partitions(n,length=r).random_element()
H = Graph()
communities = []
for comm_size,Pr in zip(community_sizes,probs):
    H=H.disjoint_union(graphs.RandomGNP(comm_size,Pr))

This is assuming that n, r and probs are given as part of the input. To see the resulting graph you can use H.show().

Assuming the input consists of n, r, and the probabilities for edges within a community; and assuming that the probability of edges between vertices in different communities is 0, then here is a possible way to generate such a graph.

community_sizes = Partitions(n,length=r).random_element()
H = Graph()
communities = []
for comm_size,Pr in zip(community_sizes,probs):
    H=H.disjoint_union(graphs.RandomGNP(comm_size,Pr))
H=H.disjoint_union(graphs.RandomGNP(comm_size,Pr),labels='integers')

This is assuming that n, r and probs are given as part of the input. To see the resulting graph you can use H.show().

Assuming the input consists of n, r, and the probabilities for edges within a community; and assuming that the probability of edges between vertices in different communities is 0, then here is a possible way to generate such a graph.

community_sizes = Partitions(n,length=r).random_element()
H = Graph()
communities = []
for comm_size,Pr in zip(community_sizes,probs):
    H=H.disjoint_union(graphs.RandomGNP(comm_size,Pr),labels='integers')

This is assuming that n, r and probs are given as part of the input. To see the resulting graph you can use H.show().

Assuming the input consists of n, r, and the probabilities for edges within a community; and assuming that the probability of edges between vertices in different communities is 0, then here is a possible way to generate such a graph.

community_sizes = Partitions(n,length=r).random_element()
H = Graph()
for comm_size,Pr in zip(community_sizes,probs):
    H=H.disjoint_union(graphs.RandomGNP(comm_size,Pr),labels='integers')

This is assuming that n, r and probs (assumed to be a list of length r containing $P_1,P_2,\ldots,P_r$) are given as part of the input. To see the resulting graph you can use H.show().