Commit 9045c372 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Implement BlockState.get_Be()

This returns the effective number of groups, taking into consideration
their sizes.
parent f7e0ec7b
......@@ -840,6 +840,16 @@ class BlockState(object):
r"Returns the total number of nonempty blocks."
return int((self.wr.a > 0).sum())
def get_Be(self):
r"""Returns the effective number of blocks, defined as :math:`e^{H}`, with
:math:`H=-\sum_r\frac{n_r}{N}\ln \frac{n_r}{N}`, where :math:`n_r` is
the number of nodes in group r.
w = numpy.array(self.wr.a, dtype="double")
w = w[w>0]
w /= w.sum()
return numpy.exp(-(w*log(w)).sum())
def get_bclabel(self, clabel=None):
r"""Returns a :class:`~graph_tool.PropertyMap` corresponding to constraint
labels for the block graph."""
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