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
args – Cf. parent class.
converter (ConverterBallot) – Default:
ConverterBallotToOrder
.matrix_weighted_majority (Matrix) – Algorithm used to compute the weighted majority matrix W. Default:
MatrixWeightedMajority
.kwargs – Cf. parent class.
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)
-
property
as_array_of_floats_
¶ The matrix, as a numpy array. It is the same as
as_array_
, but converted to floats.- Type
Array