View source: R/create_edge_list.R
create_edge_list | R Documentation |
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. If degree = 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 package
chessboard
implements all possible orientations derived from the chess
game.
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
)
nodes |
a |
method |
a |
degree |
an |
directed |
a |
reverse |
a |
self |
a |
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
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.