[graph-tool] Re: error: Received Orphaned Property Map

2021-10-05 Thread Tiago de Paula Peixoto

Am 04.10.21 um 20:27 schrieb sam.gyet...@gmail.com:

i wasn't aware of the own_property() function and can't find it in the 
graph-tool documentation (other than seeing it being used in examples involving 
visualization). whatever it does, it seems to work


just do: help(Graph.own_property)

--
Tiago de Paula Peixoto 
___
graph-tool mailing list -- graph-tool@skewed.de
To unsubscribe send an email to graph-tool-le...@skewed.de


[graph-tool] Re: running minimize_blockmodel_dl() in parallel

2021-10-05 Thread Tiago de Paula Peixoto

Am 05.10.21 um 05:06 schrieb Sam G:

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?


The line np.random.seed() initializes numpy's RNG, which different from 
the one used in graph-tool (which is in C++). You need to replace that 
line with:


   gt.seed_rng(0)


--
Tiago de Paula Peixoto 
___
graph-tool mailing list -- graph-tool@skewed.de
To unsubscribe send an email to graph-tool-le...@skewed.de