What are the pairing regulations for round-robin tournaments? I am writing a pairing program for round-robin/double round-robin/swiss tournaments. I am looking for the rules to follow while generating the pairings. There seem to be no rules in the FIDE handbook. The only rule I know is that in tournaments like the FIDE Candidates players of the same federation are paired together as early as possible. Do there exist any other restrictions, or do I just pair the players randomly such that each player plays every other player in the tournament?
I am looking for the rules to follow while generating the pairings.
  There seem to be no rules in the FIDE handbook.


The pairings are the responsibility of the arbiter and the FIDE Arbiters Commission produces a handbook which it maintains for the guidance of arbiters in the commission of their duties.

This handbook collects together various documents some of which appear in other places on the FIDE website. These include -


An annotated copy of the FIDE Laws of Chess
Guidelines for Organisers
FIDE Competition (Tournament) Rules
General Rules and Recommendations for Tournaments
International Title Regulations
FIDE Rating Regulations
Regulations for the Titles of Arbiters
Anti Cheating Guidelines
The Role of the Arbiters and their Duties



  Do there exist any other restrictions, or do I just pair the players
  randomly such that each player plays every other player in the
  tournament?


For your question the important section is section 7. Pairings in the FIDE Competition (Tournament) Rules. There it says -


  7.5 The pairings for a round robin should be made in accordance with the Berger tables (Annex 1), adjusted where necessary for double-round
  events.


So, no you do not pair the players randomly. You pair using the Berger tables. The allocation of players to start numbers is governed by the other articles in that section -


  7.1 Responsibility for the drawing of lots and the actual pairings rests with the CA.
  7.2 The drawing of lots for the first round of a round-robin competition shall be arranged by the CO, to be open to the players.
  7.3 In L1, L2: round robin competitions and preferable Swisses, the drawing of lots shall take place at least 12 hours before the start of
  the first round. In L1 all participants shall attend the ceremony of
  drawing of lots. A player who has not arrived on time for the drawing
  of lots may be included at the discretion of the CA. The first-round
  pairings shall be announced as soon as possible thereafter.
  7.4 If a player withdraws or is excluded from a competition after the drawing of lots but before the beginning of the first round, or there
  are additional entries, the announced pairings shall remain unaltered.
  Additional pairings or changes may be made at the discretion of the CA
  in consultation with the players directly involved, but only if these
  minimise amendments to pairings that have already been announced.


In response to -


  The only rule I know is that in tournaments like the FIDE Candidates
  players of the same federation are paired together as early as
  possible.


This is covered in articles 7.6 and 7.7 which specify that the Varma tables may be used in conjunction with the Berger tables to provide a way of restricting the drawing of lots to ensure this.


  7.6 If the pairings are to be restricted in any way - for example, players from the same federation shall, if possible, not meet in the
  last three rounds - this shall be communicated to the players as soon
  as possible, but not later than the start of the first round.
  7.7 For round-robin competitions this restricted drawing of lots may be done by using the Varma tables, reproduced in Annex 2, which can be
  used for competitions of 9 to 24 players


The Berger tables and Varma tables appear at the end of the FIDE Competition (Tournament) Rules