| 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().
| 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().
| 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().
| 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 $P_1,P_2,\ldots,P_r$) are given as part of the input. To see the resulting graph you can use H.show().
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.