edge_flow: Circulation (flow-field) edge covariate from a spatial vector...

View source: R/edge_covariates.R

edge_flowR Documentation

Circulation (flow-field) edge covariate from a spatial vector field

Description

Builds an antisymmetric per-edge covariate from a spatial vector field (for example wind or current), for use in directed gene-flow models. edge_gradient takes the gradient of a scalar potential, which is curl-free and yields a reversible generator whose stationary distribution is collinear with the potential. A vector flow field can carry a rotational/curl component instead, making the directed generator non-reversible and its stationary distribution non-collinear with any scalar covariate.

Usage

edge_flow(field, data)

Arguments

field

The vector field at the active graph cells: a two-column numeric matrix or data frame (x- and y-components, in vertex order), a two-layer terra::SpatRaster (sampled at the vertex coordinates), or a function of a two-column coordinate matrix returning such a two-column field.

data

A terradish_graph from deme_graph (must carry vertex_coordinates).

Details

For undirected edge (a, b) the covariate is the mean field along the edge projected onto the edge direction, c_{ab} = \tfrac{1}{2}(f_a + f_b) \cdot (xy_b - xy_a); it is antisymmetric by construction, and a directed model applies -c_{ab} to the reverse edge b \to a.

Value

A numeric vector with one entry per undirected edge in data$edge_pairs, ready to pass to a directed gene-flow model.

See Also

edge_gradient

Examples

coords <- as.matrix(expand.grid(x = 0:2, y = 0:2))
g <- deme_graph(coords, neighbours = "lattice")
field <- matrix(c(1, 0), nrow = nrow(coords), ncol = 2, byrow = TRUE)
edge_flow(field, g)

landgraph documentation built on Sept. 26, 2026, 1:08 a.m.