Creates a list of edges (links) between nodes (sampling units) based on the detection of neighbors and according to three neighborhood rules:

  1. Degree of neighborhood (argument degree): the number of adjacent nodes that will be used to create direct edges. If degree = 1, only nodes directly adjacent to the focal node will be considered as neighbors.

  2. Orientation of neighborhood (argument method): can neighbors be detecting horizontally and/or vertically and/or diagonally? The package chessboard implements all possible orientations derived from the chess game.

  3. Direction of neighborhood (arguments directed and reverse): does the sampling design has a direction? If so (directed = TRUE), the network will be considered as directed and the direction will follow the order of node labels in both axes (except if reverse = TRUE).

It's important to note that, even the package chessboard is designed to deal with spatial networks, this function does not explicitly use spatial coordinates to detect neighbors. Instead it uses the node labels. The function create_node_labels() must be used before this function to create node labels.

create_edge_list(
  nodes,
  method,
  degree = 1,
  directed = FALSE,
  reverse = FALSE,
  self = FALSE
)

Arguments

nodes

a data.frame with (at least) the following three columns: node, transect, and quadrats. Must be the output of the function create_node_labels().

method

a character of length 1. The method used to detect neighbors. One among 'pawn', 'fool', 'rook', 'bishop', 'bishop_left', 'bishop_right', 'knight', 'knight_left', 'knight_right', 'queen', 'wizard'. For further information, see the functions of the same name (i.e. pawn(), rook(), etc.).

degree

an integer of length 1. The maximum number of neighbors to search for.

directed

a logical of length 1. If FALSE (default), search for neighbors in all directions (undirected network). Otherwise, the network will be considered as directed according to the orientations of the network. The default orientation follows the order of node labels in both axes.

reverse

a logical of length 1. If TRUE, change the default orientation of the network. This argument is ignored if directed = FALSE. See examples for further detail.

self

a logical of length 1. If TRUE, a node can be its own neighbor. Default is FALSE.

Value

A data.frame with n rows (where n is the number of edges) and the following two columns:

  • from: the node label of one of the two endpoints of the edge

  • to: the node label of the other endpoint of the edge

Examples

library("chessboard")

# Two-dimensional sampling (only) ----
sites_infos <- expand.grid("transect" = 1:3, "quadrat" = 1:5)

nodes <- create_node_labels(data     = sites_infos, 
                            transect = "transect", 
                            quadrat  = "quadrat")

edges <- create_edge_list(nodes, method = "pawn", directed = TRUE)
edges
#>    from  to
#> 1   1-1 1-2
#> 2   1-2 1-3
#> 3   1-3 1-4
#> 4   1-4 1-5
#> 5   2-1 2-2
#> 6   2-2 2-3
#> 7   2-3 2-4
#> 8   2-4 2-5
#> 9   3-1 3-2
#> 10  3-2 3-3
#> 11  3-3 3-4
#> 12  3-4 3-5

edges <- create_edge_list(nodes, method = "bishop", directed = TRUE)
edges
#>    from  to
#> 1   1-1 2-2
#> 2   1-2 2-3
#> 3   1-3 2-4
#> 4   1-4 2-5
#> 5   2-1 1-2
#> 6   2-1 3-2
#> 7   2-2 1-3
#> 8   2-2 3-3
#> 9   2-3 1-4
#> 10  2-3 3-4
#> 11  2-4 1-5
#> 12  2-4 3-5
#> 13  3-1 2-2
#> 14  3-2 2-3
#> 15  3-3 2-4
#> 16  3-4 2-5