About the blocks from the minimize_nested_blockmodel_dl

Hello,

I've been using graph tool for about 3 weeks now. I just ran into it while
searching for a modularity method for a bipartite network.

I am amazed by graph tool and the algorithms within. But I am having truble
with a basic question (at least I think it is).

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?

In short, I want to write down (terminal or file) the vertices from the
graph (with its node names) for each level and respective block. I suppose
it can be done, because the info is in the draw, but I do not know how.

Thanks in advance! Great job with graph tool, and the stochastic block
model (which I haven't completely understood, but I will).

Tech info:
I work with graph-tool 2.16-1 under Arch Linux, with Python 3.5, if that
matters.
The bipartite network have 2230 vertices and 246764 edges .

From the state summary:

l: 0, N: 2230, B: 174
l: 1, N: 174, B: 68
l: 2, N: 68, B: 26
l: 3, N: 26, B: 9
l: 4, N: 9, B: 3
l: 5, N: 3, B: 1

Have a great day!

attachment.html (6.77 KB)

Hi Rogelio

I'm just another user of graph tool, and I'm not familiar with the function
that you've mentioned, but I can tell you how I do my naming.

I create a vertex property map for my vertices and add a string value to
each vertex which is going to be their name (the vertex number as integer
transformed into a string). Now if I remove a vertex, or something changes,
the property map will stay with the vertices and I can call them.
If the function you are talking about will generate a new graph, I don't
know how to solve that, but if you make your graph to be simplified to that
graph, you will have the names.
I'm sure there is an easier way, but I will leave that to the experts :slight_smile:

Good luck

Csongor

attachment.html (7.98 KB)

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])
  3

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])
  5

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

Best,
Tiago