Skip to contents

Extracts and formats local extrema information from hop-neighborhood results into a data frame.

Usage

create.hop.nbhd.extrema.df(
  result,
  include_spurious = TRUE,
  threshold = NULL,
  sort_by_value = FALSE,
  vertex_column_name = "vertex",
  label_style = c("mM", "minmax"),
  reorder = sort_by_value
)

Arguments

result

A list-like object containing hop neighborhood information. Must contain components lmin_hop_nbhds and lmax_hop_nbhds. If inherits(result, "gflow_cx"), the spurious threshold may be read from an attribute (see threshold).

include_spurious

Logical scalar. If FALSE, remove extrema with hop_idx <= threshold.

threshold

Numeric scalar or NULL. If NULL and result is a gflow_cx, attempts to read attr(result, "hop.idx.threshold") and then attr(result, "hop_idx_threshold") for backward compatibility. If still NULL, defaults to 2.

sort_by_value

Logical scalar. If TRUE, labels (and optionally rows) are ordered by function value: minima ascending, maxima descending.

vertex_column_name

Character scalar. Name of the vertex column.

label_style

Character scalar. Either "mM" (default; labels m1/M1) or "minmax" (labels min1/max1).

reorder

Logical scalar. If TRUE, reorder rows so minima (ascending value) come first, followed by maxima (descending value). Defaults to sort_by_value.

Value

A data frame with columns:

  • vertex (or renamed): integer vertex index

  • hop_idx: numeric hop index

  • is_max: integer 0 (min) / 1 (max)

  • label: character extremum label

  • value: numeric extremum value (NA if unavailable)

  • spurious: logical flag (hop_idx <= threshold)