Commit 60b36065 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

(Nested)BlockState: fix clabel propagation

parent 03a8fa2c
......@@ -317,7 +317,7 @@ class BlockState(MCMCState, MultiflipMCMCState, MultilevelMCMCState,
if clabel is not None:
if isinstance(clabel, PropertyMap):
self.clabel = self.g.own_property(clabel).copy("int")
self.clabel = self.g.own_property(clabel)
else:
self.clabel = self.g.new_vp("int")
self.clabel.fa = clabel
......@@ -710,10 +710,11 @@ class BlockState(MCMCState, MultiflipMCMCState, MultilevelMCMCState,
labels for the block graph."""
bclabel = self.bg.new_vertex_property("int")
reverse_map(self.b, bclabel)
idx = self.vweight.a > 0
reverse_map(self.b.a[idx], bclabel)
if clabel is None:
clabel = self.clabel
pmap(bclabel, clabel)
pmap(bclabel, clabel.a[idx])
return bclabel
def _set_bclabel(self, bstate):
......
......@@ -432,6 +432,17 @@ class OverlapBlockState(BlockState):
_prop("v", self.base_g, b))
return b
def get_bclabel(self, clabel=None):
r"""Returns a :class:`~graph_tool.VertexPropertyMap` corresponding to constraint
labels for the block graph."""
bclabel = self.bg.new_vertex_property("int")
reverse_map(self.b, bclabel)
if clabel is None:
clabel = self.clabel
pmap(bclabel, clabel)
return bclabel
@copy_state_wrap
def entropy(self, adjacency=True, dl=True, partition_dl=True,
degree_dl=True, degree_dl_kind="distributed", edges_dl=True,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment