How to know exactly the number of blocks created by SBM in graph-tool?

I will use this graph right here as an example.

import pandas as pd
import graph_tool.all as gt
g = gt.collection.data["polbooks"]
state = gt.minimize_blockmodel_dl(g)
state.draw(pos=g.vp["pos"], vertex_shape=state.get_blocks())

image

As you can see only 3 blocks are formed, however when I use these commands:

state.get_B() #number of blocks

returns 105

state.get_N() #Returns the total number of nodes.

returns 105

state.get_nonempty_B()

returns 3

My question is, as I know exactly how many communities were formed, why when using the commands above do I have the number of communities formed to be 105 when we clearly see that there are only 3 and how do I get exactly which nodes are in each community?

The first function get_B() returns the number of groups, including empty ones, while get_nonempty_B() returns the number of nonempty ones, which is what you want.

To obtain the partition, you want the get_blocks() function.