Generating stochastic block model with different intra-group and inter-group probabilities
Dear all, I am trying to generate a stochastic block model in the graph_tool. Specifically, I am trying to construct a network with exactly 2 blocks such that the probabilities inside the groups are higher than that of the between the groups (assortative structure) but the probabilities inside the groups are not identical for two groups (say 0.9 for the first group and 0.6 for the second group). The extreme case of this would be to make the probability between the groups equal to zero which should give me two isolated modules. My code given below however fails to generate these two models. Can somebody kindly explain me my mistake? import numpy as np import graph_tool.all as gt N = 1000 ave_deg = 10 block = np.random.randint(1, 3, N) def f(): ave_deg = 5 return np.random.poisson(ave_deg) def corr(a, b): if a == 1 and b == 1: return 0.6 elif a == 2 and b == 2 : return 0.9 else: return 0. G, bm = gt.random_graph(N, deg_sampler = f, directed = False, model = "blockmodel-traditional", block_membership = block, vertex_corr = corr) largest_comp = gt.Graph(gt.GraphView(G, vfilt = gt.label_largest_component(G)), prune = True) gt.graph_draw(G) Thank you Snehal -- Snehal Madhukar Shekatkar Pune India
On 28.11.2016 09:06, Snehal Shekatkar wrote:
The extreme case of this would be to make the probability between the groups equal to zero which should give me two isolated modules. My code given below however fails to generate these two models. Can somebody kindly explain me my mistake?
What problems do you observe, exactly? -- Tiago de Paula Peixoto <tiago@skewed.de>
Basically, instead of seeing two disconnected modules, I see that those modules are connected by few links. (There are some isolated nodes which is not a problem I guess). On 28-Nov-2016 2:55 pm, "Tiago de Paula Peixoto" <tiago@skewed.de> wrote:
On 28.11.2016 09:06, Snehal Shekatkar wrote:
The extreme case of this would be to make the probability between the groups equal to zero which should give me two isolated modules. My code given below however fails to generate these two models. Can somebody kindly explain me my mistake?
What problems do you observe, exactly?
-- Tiago de Paula Peixoto <tiago@skewed.de>
_______________________________________________ graph-tool mailing list graph-tool@skewed.de https://lists.skewed.de/mailman/listinfo/graph-tool
On 28.11.2016 09:41, Snehal Shekatkar wrote:
Basically, instead of seeing two disconnected modules, I see that those modules are connected by few links. (There are some isolated nodes which is not a problem I guess).
The algorithm implemented is a MCMC, which needs to equilibrate. Try passing something like niter=1000 to the random_graph() function. -- Tiago de Paula Peixoto <tiago@skewed.de>
That worked. Thank you very much! Snehal On Mon, Nov 28, 2016 at 3:36 PM, Tiago de Paula Peixoto <tiago@skewed.de> wrote:
On 28.11.2016 09:41, Snehal Shekatkar wrote:
Basically, instead of seeing two disconnected modules, I see that those modules are connected by few links. (There are some isolated nodes which is not a problem I guess).
The algorithm implemented is a MCMC, which needs to equilibrate. Try passing something like niter=1000 to the random_graph() function.
-- Tiago de Paula Peixoto <tiago@skewed.de>
_______________________________________________ graph-tool mailing list graph-tool@skewed.de https://lists.skewed.de/mailman/listinfo/graph-tool
-- Snehal Madhukar Shekatkar Pune India
participants (2)
-
Snehal Shekatkar -
Tiago de Paula Peixoto