Skip to contents

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.

Usage

get.nbrs(extr.obj, id)

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 maxima

  • lmin_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 index

  • value: Numeric value at the vertex

  • hop_idx: Numeric hop index

  • nbhd_df: Numeric matrix of neighborhood vertices

  • nbhd_bd_df: Numeric matrix of neighborhood boundary vertices

Details

The function performs the following steps:

  1. Looks up the label in extrema_df to find the corresponding vertex

  2. Determines whether the extremum is a maximum (is_max = 1) or minimum (is_max = 0)

  3. Selects the appropriate neighborhood list (lmax_hop_nbhds or lmin_hop_nbhds)

  4. Extracts the component with the matching vertex index

See also

Related extrema analysis functions (if applicable)

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