[graph-tool] About the blocks from the minimize_nested_blockmodel_dl

Tiago de Paula Peixoto tiago at skewed.de
Sat May 28 13:49:35 CEST 2016

On 26.05.2016 04:22, Rogelio Basurto wrote:
> I am reading a bipartite network from a graphml file, then I do some
> filtering and finally I construct the minimize_nested_blockmodel_dl as
> in the example. Then I draw it, just like in the example, and it looks
> great. I manage to draw it with the node names and they are fine.
> Then, I would like to check the names of the nodes in the different
> blocks, by the levels they are arranged from the stochastic nested
> block model. But I do not know how to do that.
> I found the function get_bstack() for the NestedBlockState object, but
> the index in those vertices are from 0 to N, where N is the number of
> vertices per level (of the model, not from my graph, I think), then
> how do I associate my original vertex index (which has its name) to
> those graphs from the different levels?

The partition of nodes in the first level is obtained via:

   b = state.levels[0].get_blocks()

This is a vertex property map that says to which block a node of your
network belongs. For example:

  >>> print(b[10])

The above means that vertex 10 belongs to group 3. The same can be done
for the higher levels of the hierarchy, i.e.

  >>> b = state.levels[1].get_blocks()
  >>> print(b[3])

The group number 3 in the first level, belongs to group number 5 in the
second level. An so on.


Tiago de Paula Peixoto <tiago at skewed.de>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <https://lists.skewed.de/pipermail/graph-tool/attachments/20160528/5d190a79/attachment.asc>

More information about the graph-tool mailing list