Commit a4d7dcf3 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Add parameter 'b' to collect_vertex_marginals()

This allows arbitrary partitions to be used in the calculation.
parent 9045c372
......@@ -2083,7 +2083,7 @@ class BlockState(object):
return p
def collect_vertex_marginals(self, p=None, unlabel=False, update=1):
def collect_vertex_marginals(self, p=None, b=None, unlabel=False, update=1):
r"""Collect the vertex marginal histogram, which counts the number of times a
node was assigned to a given block.
......@@ -2092,9 +2092,12 @@ class BlockState(object):
p : :class:`~graph_tool.PropertyMap` (optional, default: ``None``)
p : :class:`~graph_tool.VertexPropertyMap` (optional, default: ``None``)
Vertex property map with vector-type values, storing the previous block
membership counts. If not provided, an empty histogram will be created.
b : :class:`~graph_tool.VertexPropertyMap` (optional, default: ``None``)
Vertex property map with group partition. If not provided, the
state's partition will be used.
unlabel : bool (optional, default: ``False``)
If ``True``, a canonical labelling of the groups will be used, so
that each partition is uniquely represented.
......@@ -2144,9 +2147,9 @@ class BlockState(object):
if p is None:
p = self.g.new_vp("vector<double>")
b = self.b
p = self.g.new_vp("vector<int>")
if b is None:
b = self.b
if unlabel:
b = perfect_prop_hash([b])[0]
Supports Markdown
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