The package chessboard implements different methods for
detecting neighbors. All are derived from the chess game and
allow user to define complex moves to create direct edges (links)
between nodes (sampling units). The following table provides a
description of the chess pieces available in
chessboard.
| Function | 2D network | Transect only | Quadrat only | Description |
|---|---|---|---|---|
pawn() |
✅ | ❌ | ✅ | Finds neighbors vertically (i.e. along a transect) |
fool() |
✅ | ✅ | ❌ | Finds neighbors horizontally (i.e. along a quadrat) |
rook() |
✅ | ❌ | ❌ | Finds neighbors vertically and horizontally |
bishop()* |
✅ | ❌ | ❌ | Finds neighbors along the two diagonals |
knight()* |
✅ | ❌ | ❌ | Finds neighbors in ‘L’ shape |
queen() |
✅ | ❌ | ❌ | Finds neighbors horizontally, vertically, and diagonally |
wizard() |
✅ | ❌ | ❌ | Finds neighbors in all directions |
* These two chess pieces each have two variants:
bishop_left(), bishop_right() and
knight_left(), knight_right().
In this vignette, we use an extended version (9 transects x 9
quadrats) of the network used in Casajus et al. (2023) to
illustrate methods for detecting neighbors implemented in
chessboard and the impact of the different arguments.
The
pawncan detect neighbors vertically, i.e. among quadrats along a transect.
The function pawn() can be used to detect neighbors
(black dots in Fig. 1) of a specific node (red dot in Fig. 1).
User can change the default settings (Fig. 1A), by adding
directionality (directed = TRUE, Fig. 1B) and reversing the
default directionality (directed = TRUE and
reverse = TRUE, Fig. 1C).
Figure 1. Moves of the Pawn (with degree = 4)
Figure 2 shows the connectivity matrix of the 9 x 9 network when
neighbors of all nodes are detected by the pawn method and
with a degree of neighborhood of 4.
Figure 2. Connectivity matrices of the Pawn (with degree = 4)
The
foolcan detect neighbors horizontally, i.e. among transects along a quadrat.
The function fool() can be used to detect neighbors
(black dots in Fig. 3) of a specific node (red dot in Fig. 3).
User can change the default settings (Fig. 3A), by adding
directionality (directed = TRUE, Fig. 3B) and reversing the
default directionality (directed = TRUE and
reverse = TRUE, Fig. 3C).
Figure 3. Moves of the Fool (with degree = 4)
Figure 4 shows the connectivity matrix of the 9 x 9 network when
neighbors of all nodes are detected by the fool method and
with a degree of neighborhood of 4.
Figure 4. Connectivity matrices of the Fool (with degree = 4)
The
rookcan detect neighbors both horizontally and vertically, i.e. among transects along a quadrat and among quadrats along a transect.
The function rook() can be used to detect neighbors
(black dots in Fig. 5) of a specific node (red dot in Fig. 5).
User can change the default settings (Fig. 5A), by adding
directionality (directed = TRUE, Fig. 5B) and reversing the
default directionality (directed = TRUE and
reverse = TRUE, Fig. 5C).
Figure 5. Moves of the Rook (with degree = 4)
Figure 6 shows the connectivity matrix of the 9 x 9 network when
neighbors of all nodes are detected by the rook method and
with a degree of neighborhood of 4.
Figure 6. Connectivity matrices of the Rook (with degree = 4)
The
bishopcan detect neighbors diagonally.
The function bishop() can be used to detect neighbors
(black dots in Fig. 7) of a specific node (red dot in Fig. 7).
User can change the default settings (Fig. 7A), by adding
directionality (directed = TRUE, Fig. 7B) and reversing the
default directionality (directed = TRUE and
reverse = TRUE, Fig. 7C).
Figure 7. Moves of the Bishop (with degree = 4)
Figure 8 shows the connectivity matrix of the 9 x 9 network when
neighbors of all nodes are detected by the bishop method
and with a degree of neighborhood of 4.
Figure 8. Connectivity matrices of the Bishop (with degree = 4)
The
knighthas a complex move, like an ‘L’ shape. It’s the difference between thewizardand thequeen.
The function knight() can be used to detect neighbors
(black dots in Fig. 9) of a specific node (red dot in Fig. 9).
User can change the default settings (Fig. 9A), by adding
directionality (directed = TRUE, Fig. 9B) and reversing the
default directionality (directed = TRUE and
reverse = TRUE, Fig. 9C).
Figure 9. Moves of the Knight (with degree = 4)
Figure 10 shows the connectivity matrix of the 9 x 9 network when
neighbors of all nodes are detected by the knight method
and with a degree of neighborhood of 4.
Figure 10. Connectivity matrices of the Knight (with degree = 4)
The
queencan detect neighbors horizontally, vertically and diagonally. It’s a combination therookand thebishop.
The function queen() can be used to detect neighbors
(black dots in Fig. 11) of a specific node (red dot in Fig. 11).
User can change the default settings (Fig. 11A), by adding
directionality (directed = TRUE, Fig. 11B) and reversing
the default directionality (directed = TRUE and
reverse = TRUE, Fig. 11C).
Figure 11. Moves of the Queen (with degree = 4)
Figure 12 shows the connectivity matrix of the 9 x 9 network when
neighbors of all nodes are detected by the queen method and
with a degree of neighborhood of 4.
Figure 12. Connectivity matrices of the Queen (with degree = 4)
The
wizardcan detect neighbors in any direction. It’s a combination thequeenand theknight.
The function wizard() can be used to detect neighbors
(black dots in Fig. 13) of a specific node (red dot in Fig. 13).
User can change the default settings (Fig. 13A), by adding
directionality (directed = TRUE, Fig. 13B) and reversing
the default directionality (directed = TRUE and
reverse = TRUE, Fig. 13C).
Figure 13. Moves of the Wizard (with degree = 4)
Figure 14 shows the connectivity matrix of the 9 x 9 network when
neighbors of all nodes are detected by the wizard method
and with a degree of neighborhood of 4.
Figure 14. Connectivity matrices of the Wizard (with degree = 4)
It’s possible to create any kind of scenarios by combining the
previous moves and by changing the values of the arguments
degree, directed, and
reverse.
Figure 15. Custom moves
Casajus N, Rievrs Borges E, Tabacchi E, Fried G & Mouquet N (2023) chessboard: An R package for creating network connections based on chess moves. R package version 0.1. URL: https://github.com/frbcesab/chessboard.