In my network, they have a weight value for each vertex, after applying the algorithm I need to add this weight to each group in the hierarchy. So it would have a total weight of each of group B.

g = gt.Graph(directed=True)

dh['Cidades 1'] = g.add_vertex()

g.add_edge_list(dg.values, hashed =True)

weights = df['Valores']

ew = g.new_edge_property('double')

ew.a = weights

g.ep['edge_weight'] = ew

state = gt.minimize_nested_blockmodel_dl(g, state_args=dict(recs=[g.ep.edge_weight],

rec_types=["discrete-binomial"]))

l: 0, N: 5550, B: 283

l: 1, N: 283, B: 57

l: 2, N: 57, B: 14

l: 3, N: 14, B: 3

l: 4, N: 3, B: 1

l: 5, N: 1, B: 1

From the code below I have the table of the corresponding numbers of each node, I just don't know if they are in order, if it's in order with the corresponding nodes of the previous hierarchy my problem is already solved, just add the similar. For example I need to add all the weights of group 1 of hierarchy 0, then I need to do the same for group 1 of hierarchy 1, so on. Could you help me write down the weight of the group?

def r(i):

return levels[5].get_blocks()[i]

hierarquia1 = []

for i in range(5550):

hierarquia1.append(r(i))

attachment.html (1.93 KB)