Retrieves the neighborhood component from an extrema result object based on the specified label identifier. The function automatically determines whether to extract from local maxima or local minima neighborhoods based on the extremum type.
Arguments
- extr.obj
A list object containing extrema analysis results with the following components:
extrema_df: A data frame with columns 'vertex', 'label', and 'is_max' (among others)lmax_hop_nbhds: A list of neighborhood objects for local maximalmin_hop_nbhds: A list of neighborhood objects for local minima
- id
A character string specifying the label of the extremum to extract (e.g., "M1", "M12", "m11", etc.). Labels starting with "M" typically indicate maxima, while "m" indicates minima.
Value
A list containing the neighborhood information for the specified extremum with the following components:
vertex: Integer vertex indexvalue: Numeric value at the vertexhop_idx: Numeric hop indexnbhd_df: Numeric matrix of neighborhood verticesnbhd_bd_df: Numeric matrix of neighborhood boundary vertices
Details
The function performs the following steps:
Looks up the label in
extrema_dfto find the corresponding vertexDetermines whether the extremum is a maximum (is_max = 1) or minimum (is_max = 0)
Selects the appropriate neighborhood list (
lmax_hop_nbhdsorlmin_hop_nbhds)Extracts the component with the matching vertex index
Examples
extr.obj <- list(
extrema_df = data.frame(
label = c("M1", "m1"),
vertex = c(3, 2),
is_max = c(1, 0)
),
lmax_hop_nbhds = list(
list(vertex = 3, value = 0.8, hop_idx = 1, nbhd_df = matrix(c(3, 0), ncol = 2))
),
lmin_hop_nbhds = list(
list(vertex = 2, value = 0.2, hop_idx = 1, nbhd_df = matrix(c(2, 0), ncol = 2))
)
)
M1.nbhd <- get.nbrs(extr.obj, "M1")
M1.nbhd$vertex
M1.nbhd$hop_idx