Hi Tiago,
sometimes, when delete the graph and create a new one, then plot it, the
plotted graph is shown upside down (in terms of the node text). So how could
we control the orientation of the graph? Or which parameter we should use to
always make node text shown in a correct orientation. Thanks a lot.
--
View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com…
Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.

Hi,
I'm suffering from the same issue mentioned in this post:
https://git.skewed.de/count0/graph-tool/issues/174
Namely, I'm trying to draw a graph that includes a lot of self-looping
edges, and my labels are being printed upside down. If I remove the
self-loops the labels are shown the right way up.
Is there a fix for it?
Thanks,
Charlie
--
View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com…
Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.

Hello,
I'm studying political coalitions over time (three time slices) and across discrete types of relationships (collaboration, ideological similarity, and discursive similarity). Since graph-tool offers (the only) principled approach that does not require arbitrary user-specified parameters (such as 'resolution' or 'coupling'), I would very much like to use it for my analysis.
I'm trying to fit a SBM to a graph with edges divided into distinct layers (three time slices X three types of relationships). Each edge has a discrete weight in the range of [0, 3], with weight referring to the 'strength' of the relationship. Not all nodes participate in all layers.
I'm interested in how/if the block membership varies across layers that I expect to be somewhat dependent on one another (hence I would like to avoid fitting a separate SBM to each layer). In my ideal scenario, I would be using the NestedBlockState with LayeredBlockState as base and allowing for overlaps across layers:
state=NestedBlockState(g, base_type=LayeredBlockState, state_args=dict(deg_corr=True, overlap=True, layers=True, ec=g.ep.layer, recs=[g.ep.weight], rec_types=["discrete-binomial"]))
dS, nmoves=0, 0
for i in range(100):
ret=state.multiflip_mcmc_sweep(niter=10)
dS+=ret[0]
nmoves+=ret[1]
print("Change in description length:", dS)
print("Number of accepted vertex moves:", nmoves)
mcmc_equilibrate(state, wait=1000, mcmc_args=dict(niter=10), verbose=True)
bs=[]
def collect_partitions(s):
global bs
bs.append(s.get_bs())
mcmc_equilibrate(state, force_niter=10000, mcmc_args=dict(niter=10), verbose=True, callback=collect_partitions)
pm=PartitionModeState(bs, nested=True, converge=True)
pv=pm.get_marginal(g)
bs=pm.get_max_nested()
state=state.copy(bs=bs)
Two questions:
Q1)
This is taking very long (days) on a high performance cluster and actually I haven't seen it finishing up for once. Is my model specification correct or simply too complex? If the latter, is there a better strategy to perform my analysis? All I can think of is to revert to a non-nested model and/or reduce the number of layers and/or edges:
state=LayeredBlockState(g, deg_corr=True, overlap=True, layers=True, ec=g.ep.layer, recs=[g.ep.weight], rec_types=["discrete-binomial"])
dS, nattempts, nmoves=state.multiflip_mcmc_sweep(niter=1000)
print("Change in description length:", dS)
print("Number of accepted vertex moves:", nmoves)
mcmc_equilibrate(state, wait=1000, nbreaks=2, mcmc_args=dict(niter=10), verbose=True)
bs=[]
def collect_partitions(s):
global bs
bs.append(s.b.a.copy())
mcmc_equilibrate(state, force_niter=10000, mcmc_args=dict(niter=10), verbose=True, callback=collect_partitions)
pm=PartitionModeState(bs, converge=True)
pv=pm.get_marginal(g)
Q2)
Say that the model runs and yields a neat NestedBlockState (or LayeredBlockState) object with X overlapping blocks, 9 layers, degree-corrected, with 2 edge covariates, for graph <Graph object, undirected, with 220 vertices and 11322 edges, 2 internal vertex properties, 4 internal edge properties>.
Now, in previous posts there are mentions about the number of nodes multiplying by the number of layers when 'overlap=True', but in my experiments with only two layers, this does not seem to be the case and I struggle to find a way to extract the layer-specific block and respective memberships of nodes.
I've tried iteration over vertices, but what I eventually need is a 2d_array [y=all nodes in g, x=all layers in g, values=most likely block membership] in order to map how/if the block membership of each node varies across those layers in which they participate (ideally somehow denoting non-participation in the layer with NaN or some unique value). Is there some way to get there?
l=state.get_levels()[0] #NestedBlockState
B=l.get_nonempty_B()
bv=l.get_overlap_blocks()[0]
z=np.zeros((g.num_vertices(), B)) #to be filled with most likely block membership with potential overlaps across ALL layers, but I need the layer-specific information
for i in range(g.num_vertices()):
z[int(i), :len(z[v])]=bv[i].a+1
for v in range(g.num_vertices()*max(g.ep.layer)+1): #to see if the number of vertices multiplied by layers, which it didn't
print(bv[v])
Many thanks,
Arttu

Hi!
I use graph_tool.topology.shortest_distance for an all pairs shortest path calculation, what is the main run-time footprint of my algorithm and way to large.
How would you speed it up / tackle this?
I tried to sub-sample with manual source, target pairs but that's terribly inefficient since it does not use the internal bookkeeping.
Nice would be graph_tool.topology.shortest_distance(G, U, V), where U and V are lists of same length with sources / targets but that's not implemented.
Thank a lot in advance!
Stephan

hi,
i was wondering if anyone had any tips on conserving memory when running graph-tool MCMCs on large networks in parallel.
i have a large network (2GB), and about 260GB of memory, and was surprised to receive a MemoryError when i ran 10 MCMC chains in parallel using multiprocessing. my impression is that MCMC was relatively light on memory.
cheers,
-sam

hi,
i received this error while trying to assign a vertex property map to a graph, and i'm not sure how to get around it.
context: i am running minimize_blockmodel_dl() many times in parallel using microprocessing. because my graph is large, i don't want it to save multiple copies of the graph. so i am trying to only keep the block id each time. however, when i try to do this, i get the above error
here's a somewhat simplified example:
```
import graph_tool.all as gt
import multiprocessing as mp
pool = mp.Pool(5)
def fit_sbm():
state = gt.minimize_blockmodel_dl(g)
b = state.get_blocks()
return b
blocks = pool.map(fit_sbm, range(5))
pool.close
b0 = blocks[0]
membership = g.new_vertex_property("int")
membership = b0
g.vertex_properties["membership"] = b0
```
could you explain why this error comes up, and also if possible suggest an alternative way to proceed?
thanks,
-sam

hi,
here is a simple example where i run minimize_blockmodel_dl() 10 times in parallel using multiprocessing and collect the entropy. when i run this, i get the same value of entropy every single time.
```
import multiprocessing as mp
import numpy as np
import time
import graph_tool.all as gt
# load graph
g = gt.collection.data["celegansneural"]
N_iter = 10
def get_sbm_entropy():
np.random.seed()
state = gt.minimize_blockmodel_dl(g)
return state.entropy()
def _parallel_mc(iter=N_iter):
pool = mp.Pool(10)
future_res = [pool.apply_async(get_sbm_entropy) for _ in range(iter)]
res = [f.get() for f in future_res]
return res
def parallel_monte_carlo(iter=N_iter):
entropies = _parallel_mc(iter)
return entropies
parallel_monte_carlo()
```
result: [8331.810102822546, 8331.810102822546, 8331.810102822546, 8331.810102822546, 8331.810102822546, 8331.810102822546, 8331.810102822546, 8331.810102822546, 8331.810102822546, 8331.810102822546]
ultimately i would like to use this to keep entropy as well as the block membership vector for each iteration
any ideas?
cheers,
-sam

Hi Tiago,
I am not sure if this issue is sourced from graph-tool. When I try to download the public key, I get this error:
echo "deb http://downloads.skewed.de/apt bionic main" >> /etc/apt/sources.list
apt-key adv --keyserver keys.openpgp.org --recv-key 612DEFB798507F25
Error:
Executing: /tmp/apt-key-gpghome.wVeQRbY1M1/gpg.1.sh --keyserver keys.openpgp.org --recv-key 612DEFB798507F25
gpg: keyserver receive failed: General error
I did check all distributions as well.
Thank you