# Vote condorcet winner

`vote-condorcet-winner` · version 1.0.0 · Optimization & voting · free, no key needed

Compute weighted pairwise counts, a strict Condorcet winner, and the generalized Smith set.

**Use when you need to: compute Condorcet winner · calculate pairwise preference matrix · find Smith set.**

## Decide before calling

Read the [versioned contract](/v1/tools/vote-condorcet-winner/versions/1.0.0) and the supported scope below. Reuse `vote-condorcet-winner@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `vote-condorcet-winner@1.0.0` for compute Condorcet winner. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- compute Condorcet winner
- calculate pairwise preference matrix
- find Smith set
- count weighted ranked ballots
- analyze tied rankings
- analyze truncated ballots

## Not supported

- choose a winner by instant-runoff voting
- resolve strategic voting or clone independence

## Behavior

- Candidate and all output ordering exactly preserve the caller-supplied candidate order; ballot weights are positive integers.
- ranked-over-missing treats every ranked candidate as preferred to every omitted candidate; abstain excludes such pairs.
- A strict Condorcet winner has a strictly larger pairwise count than every opponent; ties do not win.
- smith_set is the generalized weak-majority top cycle: each returned candidate can reach every candidate along edges whose pairwise count is at least the reverse count.

## Input

- `candidates` (array of string, required): min items 2; max items 50; each min length 1; each max length 64
- `ballots` (array of object, required): max items 1000
- `missing_candidate_policy` (one of "ranked-over-missing", "abstain", required)

## Output

- `candidates` (array of string, required): min items 2; max items 50
- `pairwise` (array of object, required): min items 2; max items 50
- `compared_weight` (array of object, required): min items 2; max items 50
- `condorcet_winner` (string or null, required)
- `smith_set` (array of string, required): min items 1; max items 50
- `audit` (object, required)

## Limits

- max candidates: 50
- max ballots: 1000
- max weight per ballot: 1000000
- max total weight: 1000000000
- max candidate bytes: 64

## Example

Request input:

```json
{
  "candidates": [
    "A",
    "B"
  ],
  "ballots": [
    {
      "ranking": [
        [
          "A"
        ],
        [
          "B"
        ]
      ],
      "weight": 3
    },
    {
      "ranking": [
        [
          "B"
        ],
        [
          "A"
        ]
      ],
      "weight": 1
    }
  ],
  "missing_candidate_policy": "ranked-over-missing"
}
```

Response:

```json
{
  "result": {
    "candidates": [
      "A",
      "B"
    ],
    "pairwise": [
      {
        "candidate": "A",
        "counts": [
          0,
          3
        ]
      },
      {
        "candidate": "B",
        "counts": [
          1,
          0
        ]
      }
    ],
    "compared_weight": [
      {
        "candidate": "A",
        "counts": [
          0,
          4
        ]
      },
      {
        "candidate": "B",
        "counts": [
          4,
          0
        ]
      }
    ],
    "condorcet_winner": "A",
    "smith_set": [
      "A"
    ],
    "audit": {
      "ballot_count": 2,
      "total_weight": 4,
      "complete_weight": 4,
      "truncated_weight": 0,
      "tied_weight": 0
    }
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "vote-condorcet-winner",
  "version": "1.0.0",
  "input": {
    "candidates": [
      "A",
      "B"
    ],
    "ballots": [
      {
        "ranking": [
          [
            "A"
          ],
          [
            "B"
          ]
        ],
        "weight": 3
      },
      {
        "ranking": [
          [
            "B"
          ],
          [
            "A"
          ]
        ],
        "weight": 1
      }
    ],
    "missing_candidate_policy": "ranked-over-missing"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/vote-condorcet-winner/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"candidates":["A","B"],"ballots":[{"ranking":[["A"],["B"]],"weight":3},{"ranking":[["B"],["A"]],"weight":1}],"missing_candidate_policy":"ranked-over-missing"}'
```

The machine-readable contract is at [/v1/tools/vote-condorcet-winner/versions/1.0.0](/v1/tools/vote-condorcet-winner/versions/1.0.0).

### CLI

```sh
node cli.mjs run vote-condorcet-winner 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Rank borda aggregate](/tools/rank-borda-aggregate): Aggregate weighted complete or partial rankings into exact Borda scores, rank groups, and audit contributions.
- [Assignment hungarian solve](/tools/assignment-hungarian-solve): Solve a bounded rectangular integer minimum-cost assignment with explicit unmatched costs.
- [Knapsack 01 solve](/tools/knapsack-01-solve): Solve bounded 0/1 knapsack exactly and return the optimum value, weight, and lexicographically smallest index list.
- [Pareto front find](/tools/pareto-front-find): Find stable nondominated row indices and a domination witness for every excluded row using exact rational criteria.
- [Round robin schedule generate](/tools/round-robin-schedule-generate): Generate a deterministic single or double round-robin schedule with ordered rounds, home/away assignments, and byes.
