create_edge_list {chessboard}R Documentation

Create an edge list

Description

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.

Usage

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:

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

edges <- create_edge_list(nodes, method = "bishop", directed = TRUE)
edges

[Package chessboard version 0.1 Index]