Am 26.07.19 um 04:17 schrieb alexTao:
> Hi Tiago,
>
> I looked at the example in the document here
> https://graph-tool.skewed.de/static/doc/demos/inference/inference.html#sampling-from-the-posterior-distribution
> <https://graph-tool.skewed.de/static/doc/demos/inference/inference.html#sampling-from-the-posterior-distribution>
>
> .
>
> As the example shows, we can obtain vertex marginals on all hierarchical
> levels, i.e. a "vertex_pie_fractions" at each level for each node. However,
> I want to find the node partition at each level for each node according to
> the *largest* "vertex_pie_fraction". Therefore, I use the following code
>
> # Hierarchical node partition as a list of np.array
> bs = [np.array([np.argmax(list(pv[i])[j]) for j in range(len(list(pv[i])))])
> for i in range(len(pv))]
>
> where pv is exactly the one shown in the example.
>
> I believe the above line of code is correct since I have checked the results
> in several real networks with small sizes (around 200 nodes and 500 edges at
> most).
>
> But it will take a quite a long time for a large network (30k nodes with
> 400k edges or more). Is there any efficient way to do the above work?
You are creating many lists necessarily for every look iteration. A
better alternative is something like:
bs = [[pv[i][v].a.argmax() for v in state.get_levels()[i].g.vertices()]
for i in range(len(pv))]
Best,
Tiago
--
Tiago de Paula Peixoto <[email protected]>
_______________________________________________
graph-tool mailing list
[email protected]
https://lists.skewed.de/mailman/listinfo/graph-tool