votes
    Preparing search index...

    Class RankedPairs<C>

    By default, equal-strength pairs are locked simultaneously: if they would form a cycle among themselves, none are locked (most neutral outcome).

    Pass edgeSorter to lock equal-strength pairs in its order instead, like canonical Tideman; pairs it cannot tell apart still lock simultaneously. byTotalParticipation (exported from this module) is a ready-made sorter that prefers pairs where more voters expressed a preference.

    The Edge type passed to the sorter has { from, to, value, total }.

    strength measures a pair by the winner's votes ('winning-votes', the default) or by its margin ('margins'): they differ when voters tie or leave out both candidates.

    Type Parameters

    • C extends string

    Hierarchy

    • MatrixScoreMethod<C>
      • RankedPairs
    Index
    • Type Parameters

      • C extends string

      Parameters

      • i: (Matrix<C> | Profile<C>) & {
            edgeSorter?: EdgeSorter;
            strength?: Strength | undefined;
        }

      Returns RankedPairs<C>

    candidates: C[]
    strength: Strength
    isRandom: boolean = false
    label: "RankedPairs" = 'RankedPairs'
    • Ranking built by repeated wins instead of the method's own full ranking: run the method, record the winning tier, then re-run it restricted to the remaining candidates for the next place, and so on.

      Differs from ranking() whenever the method's full ranking disagrees with how it ranks subsets — e.g. instant runoff orders losers by elimination time, while iterating re-elects a winner at every place.

      Returns C[][]

    • Each pairwise win, strongest first, as groups the sorter cannot tell apart: locked together, or skipped when it would close a cycle with the pairs locked before and its whole group. The winners are those no locked pair beats; the ranking below them runs again on the rest.

      Returns RankedPairsLockStep<C>[][]

    • Result of the vote. The first item lists the winners of the vote.

      For example this ranking means that Bear wins, Sheep is second and Lion third [ [ 'Bear' ], [ 'Sheep' ], [ 'Lion' ] ]

      Returns C[][]

    • Return a new instance of the same method restricted to a subset of candidates, ranking as if only they ran.

      Parameters

      • candidates: readonly C[]

      Returns this

    • The method as an Election method, with options for its constructor and mode or label.

      Type Parameters

      Parameters

      • this: T
      • options: PropsOf<T> & { label?: string; mode?: "restricted" | "full" | "recursive" }
        • Optionallabel?: string

          Name in traces (TieBreakStep.name, StepResult.name) instead of the method's label.

        • Optionalmode?: "restricted" | "full" | "recursive"

          Which candidates the method ranks a tie among: the tied ones ('restricted', default), everyone ('full'), or the tied ones, then those of each tie that leaves, until none splits ('recursive').

      Returns readonly [
          T,
          PropsOf<T> & { label?: string; mode?: "restricted" | "full" | "recursive" },
      ]

      new Election({
      candidates,
      ballots,
      methods: [Copeland, Borda.with({ mode: 'full' })],
      })