Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

answered 7 years ago

fidbc gravatar image

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().

click to hide/show revision 2
No.2 Revision

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().

click to hide/show revision 3
No.3 Revision

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().

click to hide/show revision 4
No.4 Revision

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 P1,P2,,Pr) are given as part of the input. To see the resulting graph you can use H.show().