MatrixSchulze

class whalrus.MatrixSchulze(*args, converter: whalrus.converters_ballot.converter_ballot.ConverterBallot = None, matrix_weighted_majority: whalrus.matrices.matrix.Matrix = None, **kwargs)[source]

The Schulze matrix.

Parameters:

Examples

First, we compute a matrix W with the algorithm given in the parameter matrix_weighted_majority. The Schulze matrix gives, for each pair of candidates (c, d), the width of the widest path from c to d, where the width of a path is the minimum weight of its edges.

>>> m = MatrixSchulze(['a > b > c', 'b > c > a', 'c > a > b'], weights=[4, 3, 2])
>>> m.as_array_
array([[0, Fraction(2, 3), Fraction(2, 3)],
       [Fraction(5, 9), 0, Fraction(7, 9)],
       [Fraction(5, 9), Fraction(5, 9), 0]], dtype=object)
as_array_of_floats_

The matrix, as a numpy array. It is the same as as_array_, but converted to floats.

Type:Array
matrix_weighted_majority_

The weighted majority matrix (upon which the computation of the Schulze is based), once computed with the given profile.

Type:Matrix