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:
-
Degree of neighborhood (argument
degree
): the number of adjacent nodes that will be used to create direct edges. Ifdegree = 1
, only nodes directly adjacent to the focal node will be considered as neighbors. -
Orientation of neighborhood (argument
method
): can neighbors be detecting horizontally and/or vertically and/or diagonally? The packagechessboard
implements all possible orientations derived from the chess game. -
Direction of neighborhood (arguments
directed
andreverse
): 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 ifreverse = 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 |
method |
a |
degree |
an |
directed |
a |
reverse |
a |
self |
a |
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
edges <- create_edge_list(nodes, method = "bishop", directed = TRUE)
edges