def resolution_profile(self,<EOL>graph,<EOL>partition_type,<EOL>resolution_range,<EOL>weights=None,<EOL>bisect_func=lambda p: p.bisect_value(),<EOL>min_diff_bisect_value=<NUM_LIT:1>,<EOL>min_diff_resolution=<NUM_LIT>,<EOL>linear_bisection=False,<EOL>number_iterations=<NUM_LIT:1>,<EOL>**kwargs<EOL>):
<EOL>def clean_stepwise(bisect_values):<EOL><INDENT>for res, bisect in bisect_values.iteritems():<EOL><INDENT>best_bisect = bisect<EOL>best_quality = bisect.partition.quality(res)<EOL>for res2, bisect2 in bisect_values.iteritems():<EOL><INDENT>if bisect2.partition.quality(res) > best_quality:<EOL><INDENT>best_bisect = bisect2<EOL>best_quality = bisect2.partition.quality(res)<EOL><DEDENT><DEDENT>if best_bisect != bisect:<EOL><INDENT>bisect_values[res] = best_bisect<EOL><DEDENT><DEDENT>bisect_list = sorted([(res, part.bisect_value) for res, part in<EOL>bisect_values.iteritems()], key=lambda x: x[<NUM_LIT:0>])<EOL>for (res1, v1), (res2, v2)in zip(bisect_list,<EOL>bisect_list[<NUM_LIT:1>:]):<EOL><INDENT>if v1 == v2:<EOL><INDENT>del bisect_values[res2]<EOL><DEDENT><DEDENT>for res, bisect in bisect_values.iteritems():<EOL><INDENT>bisect.partition.resolution_parameter = res<EOL><DEDENT><DEDENT>def ensure_monotonicity(bisect_values, new_res):<EOL><INDENT>for res, bisect_part in bisect_values.iteritems():<EOL><INDENT>if bisect_values[new_res].partition.quality(res) > bisect_part.partition.quality(res):<EOL><INDENT>bisect_values[res] = bisect_values[new_res]<EOL><DEDENT><DEDENT>current_quality = bisect_values[new_res].partition.quality(new_res)<EOL>best_res = new_res<EOL>for res, bisect_part in bisect_values.iteritems():<EOL><INDENT>if bisect_part.partition.quality(new_res) > current_quality:<EOL><INDENT>best_res = new_res<EOL><DEDENT><DEDENT>bisect_values[new_res] = bisect_values[best_res]<EOL><DEDENT>def find_partition(self, graph, partition_type, weights=None, **kwargs):<EOL><INDENT>partition = partition_type(graph,<EOL>weights=weights,<EOL>**kwargs)<EOL>n_itr = <NUM_LIT:0><EOL>while self.optimise_partition(partition) > <NUM_LIT:0> and(n_itr < number_iterations or number_iterations <= <NUM_LIT:0>):<EOL><INDENT>n_itr += <NUM_LIT:1><EOL><DEDENT>return partition<EOL><DEDENT>assert issubclass(partition_type, LinearResolutionParameterVertexPartition), "<STR_LIT>"<EOL>bisect_values = {}<EOL>stack_res_range = []<EOL>stack_res_range.append(resolution_range)<EOL>BisectPartition = namedtuple('<STR_LIT>',<EOL>['<STR_LIT>', '<STR_LIT>'])<EOL>partition = find_partition(self, graph=graph, partition_type=partition_type,<EOL>weights=weights,resolution_parameter=resolution_range[<NUM_LIT:0>],<EOL>**kwargs)<EOL>bisect_values[resolution_range[<NUM_LIT:0>]] = BisectPartition(partition=partition,<EOL>bisect_value=bisect_func(partition))<EOL>partition = find_partition(self, graph=graph, partition_type=partition_type,<EOL>weights=weights, resolution_parameter=resolution_range[<NUM_LIT:1>], **kwargs)<EOL>bisect_values[resolution_range[<NUM_LIT:1>]] = BisectPartition(partition=partition,<EOL>bisect_value=bisect_func(partition))<EOL>while stack_res_range:<EOL><INDENT>current_range = stack_res_range.pop()<EOL>diff_bisect_value = abs(bisect_values[current_range[<NUM_LIT:0>]].bisect_value -<EOL>bisect_values[current_range[<NUM_LIT:1>]].bisect_value)<EOL>if current_range[<NUM_LIT:0>] > <NUM_LIT:0> and current_range[<NUM_LIT:1>] > <NUM_LIT:0> and not linear_bisection:<EOL><INDENT>diff_resolution = log(current_range[<NUM_LIT:1>]/current_range[<NUM_LIT:0>])<EOL><DEDENT>else:<EOL><INDENT>diff_resolution = abs(current_range[<NUM_LIT:1>] - current_range[<NUM_LIT:0>])<EOL><DEDENT>if diff_bisect_value > min_diff_bisect_value anddiff_resolution > min_diff_resolution:<EOL><INDENT>if current_range[<NUM_LIT:0>] > <NUM_LIT:0> and current_range[<NUM_LIT:1>] > <NUM_LIT:0> and not linear_bisection:<EOL><INDENT>new_res = sqrt(current_range[<NUM_LIT:1>]*current_range[<NUM_LIT:0>])<EOL><DEDENT>else:<EOL><INDENT>new_res = sum(current_range)/<NUM_LIT><EOL><DEDENT>stack_res_range.append((current_range[<NUM_LIT:0>], new_res))<EOL>stack_res_range.append((new_res, current_range[<NUM_LIT:1>]))<EOL>if not bisect_values.has_key(new_res):<EOL><INDENT>partition = find_partition(self, graph, partition_type=partition_type,<EOL>weights=weights, resolution_parameter=new_res, **kwargs)<EOL>bisect_values[new_res] = BisectPartition(partition=partition,<EOL>bisect_value=bisect_func(partition))<EOL>ensure_monotonicity(bisect_values, new_res)<EOL><DEDENT><DEDENT><DEDENT>clean_stepwise(bisect_values)<EOL>return sorted((bisect.partition for res, bisect in<EOL>bisect_values.iteritems()), key=lambda x: x.resolution_parameter)<EOL>
Use bisectioning on the resolution parameter in order to construct a
        resolution profile.

        Parameters
        ----------
        graph
          The graph for which to construct a resolution profile.

        partition_type
          The type of :class:`~VertexPartition.MutableVertexPartition` used
          to find a partition (must support resolution parameters obviously).

        resolution_range
          The range of resolution values that we would like to scan.

        weights
          If provided, indicates the edge attribute to use as a weight.

        Returns
        -------
        list of :class:`~VertexPartition.MutableVertexPartition`
          A list of partitions for different resolutions.

        Other Parameters
        ----------------
        bisect_func
          The function used for bisectioning. For the methods currently
          implemented, this should usually not be altered.

        min_diff_bisect_value
          The difference in the value returned by the bisect_func below which the
          bisectioning stops (i.e. by default, a difference of a single edge does
          not trigger further bisectioning).

        min_diff_resolution
          The difference in resolution below which the bisectioning stops. For
          positive differences, the logarithmic difference is used by default, i.e.
          ``diff = log(res_1) - log(res_2) = log(res_1/res_2)``, for which ``diff >
          min_diff_resolution`` to continue bisectioning. Set the linear_bisection
          to true in order to use only linear bisectioning (in the case of negative
          resolution parameters for example, which can happen with negative
          weights).

        linear_bisection
          Whether the bisectioning will be done on a linear or on a logarithmic
          basis (if possible).

        number_iterations
          Indicates the number of iterations of the algorithm to run. If negative
          (or zero) the algorithm is run until a stable iteration.

        Examples
        --------
        >>> G = ig.Graph.Famous('Zachary')
        >>> optimiser = louvain.Optimiser()
        >>> profile = optimiser.resolution_profile(G, louvain.CPMVertexPartition,
        ...                                        resolution_range=(0,1))