def __init__(self, graph, initial_membership=None, weights=None):
if initial_membership is not None:<EOL><INDENT>initial_membership = list(initial_membership)<EOL><DEDENT>super(ModularityVertexPartition, self).__init__(graph, initial_membership)<EOL>pygraph_t = _get_py_capsule(graph)<EOL>if weights is not None:<EOL><INDENT>if isinstance(weights, str):<EOL><INDENT>weights = graph.es[weights]<EOL><DEDENT>else:<EOL><INDENT>weights = list(weights)<EOL><DEDENT><DEDENT>self._partition = _c_louvain._new_ModularityVertexPartition(pygraph_t,<EOL>initial_membership, weights)<EOL>self._update_internal_membership()<EOL>
Parameters
----------
graph : :class:`ig.Graph`
  Graph to define the partition on.

initial_membership : list of int
  Initial membership for the partition. If :obj:`None` then defaults to a
  singleton partition.

weights : list of double, or edge attribute
  Weights of edges. Can be either an iterable or an edge attribute.