Skip to contents

Detect Local Extrema in a Graph

Usage

detect.local.extrema(
  adj.list,
  length.list,
  y,
  max.radius,
  min.neighborhood.size,
  detect.maxima = TRUE,
  custom.prefix = NULL
)

Arguments

adj.list

Graph adjacency list using 1-based vertex indices.

length.list

Edge-length list aligned with adj.list.

y

Numeric vertex function values.

max.radius

Maximum graph-geodesic radius for neighborhoods.

min.neighborhood.size

Minimum neighborhood size required.

detect.maxima

Logical; if TRUE, detect maxima, otherwise minima.

custom.prefix

Optional label prefix.

Value

A local_extrema object. Its scalar logical detect.maxima component records whether maxima or minima were requested, even when no extrema are found. The per-extremum is_maxima and type vectors are empty in that case.

Details

Summaries use the recorded detection setting for empty results. Empty objects saved by older versions lack this setting; their summaries report NA for the extrema type because it cannot be recovered from empty vectors.

Examples

chain <- create.graph("chain", n = 5)
extrema <- detect.local.extrema(graph.adjacency(chain), graph.lengths(chain), y = c(1, 3, 1, 2,
    0), max.radius = 1, min.neighborhood.size = 2)
extrema$vertices
#> [1] 2 4