Thank you! I'll try that out. 

On Sat, Aug 5, 2017 at 11:51 AM, Alexandre Hannud Abdo <abdo@member.fsf.org> wrote:
Ni!

What you're looking for is the 'project_level' method of NestedBlockState:

some_level = 2
blocks = state.project_level( some_level ).get_blocks()
block_for_v_at_level = blocks[ some_vertex ]

Hope this helps,

ale
.~´



On Sat, Aug 5, 2017 at 5:29 PM, lenail <lenail@mit.edu> wrote:
Hello Graph Tool developers,

I'm interested in the nested stochastic block model (nsbm). What interests
me most is: when I fit the model, where did each of my nodes get clustered?
The closest function I can find to this in the API by reading the docs is:

nsbm.get_bs()

which returns


[PropertyArray([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], dtype=int32),
 PropertyArray([1, 1, 2, 2, 3, 4, 5, 0, 6, 4, 7, 1, 1, 4, 0, 5, 0, 0, 8, 2,
                6, 5, 6, 6, 2, 2, 3, 3, 1, 1, 0, 7, 5, 5, 7, 3, 3, 6, 3, 7,
                9, 8, 0, 8, 6, 7, 7], dtype=int32),
 PropertyArray([ 0,  1,  1, 13,  4,  5,  6,  7,  8,  9, 10,  4, 11,  0, 12,
                13, 10, 14, 15,  4, 16, 17, 18,  5, 19, 20, 21, 22, 23,  9,
                16, 14,  7, 24, 25, 26,  9, 27, 28, 29, 30,  5, 35, 14, 23,
                30, 11, 41, 31, 13, 32,  6, 25, 33,  8, 34,  0, 12,  4, 16,
                32, 35,  0, 28, 36, 13, 30, 27, 36, 11, 19, 13, 26, 13, 36,
                37, 23, 28, 32, 19, 25, 29,  5, 24, 20, 27, 25,  4, 17, 36,
                22, 11, 15, 12, 14,  2,  5, 38,  9,  9, 24, 39, 29, 13, 34,
                17,  8, 20,  9,  5, 23,  8,  9, 40, 40, 27, 31, 40, 41, 10,
                 3, 12, 25, 38, 20, 40,  9,  9, 25, 42, 10, 24, 43,  3, 37,
                 2, 17, 34, 35, 21, 38, 32, 26, 22, 28, 13, 17, 44, 45, 36,
                42, 26, 17, 27, 24, 40, 39,  9, 13,  5, 43, 38, 35, 30, 13,
                36, 13, 11, 14, 40, 40, 12,  3, 40, 38,  1, 40, 21, 42,  9,
                10, 29, 43, 45, 40, 31, 46, 40, 31,  5, 42, 40, 14, 11, 38,
                34, 31, 34, 40, 31, 31, 45, 10,  4], dtype=int32),
 PropertyArray([  0,   1,   2, ..., 163,  98,  18], dtype=int32)]


The solution I ended up using was:


vertex_name = nsbm.g.vertex_properties['_graphml_vertex_id']

clustering = [(nsbm.g.vertex_index[v], vertex_name[v],
nsbm.get_bs()[0][nsbm.g.vertex_index[v]]) for v in nsbm.g.vertices()]

clustering = [(i, name, base_clustering, nsbm.get_bs()[1][level0]) for i,
name, level0 in clustering]

clustering = [(i, name, level0, level1, nsbm.get_bs()[2][level1]) for i,
name, level0, level1 in clustering]

clustering = [(i, name, level0, level1, level2, nsbm.get_bs()[3][level2])
for i, name, level0, level1, level2 in clustering]


at which point I had my result. Is there a less verbose way of putting this?
If not, this serves as a feature request to add such a method, maybe called
"get_clabels" ?



--
View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/How-to-effectively-get-the-nested-blockmodel-block-memberships-of-each-of-the-nodes-in-your-graph-tp4027329.html
Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.
_______________________________________________
graph-tool mailing list
graph-tool@skewed.de
https://lists.skewed.de/mailman/listinfo/graph-tool


_______________________________________________
graph-tool mailing list
graph-tool@skewed.de
https://lists.skewed.de/mailman/listinfo/graph-tool