Perform Harmonic Smoothing on Graph Function Values
Source:R/harmonic_smoother.R
perform.harmonic.smoothing.RdApplies harmonic smoothing to function values defined on vertices of a graph, preserving values at the boundary of a specified region while smoothly interpolating interior values. This function implements a discrete Laplace equation solution using weighted averaging.
Usage
perform.harmonic.smoothing(
adj.list,
weight.list,
values,
region.vertices,
max.iterations = 100,
tolerance = 1e-06
)Arguments
- adj.list
A list of integer vectors, where each vector contains indices of vertices adjacent to the corresponding vertex. Indices must be 1-based.
- weight.list
A list of numeric vectors containing weights of edges corresponding to adjacencies in
adj.list.- values
A numeric vector of function values defined at each vertex.
- region.vertices
An integer vector of vertex indices (1-based) defining the region to be smoothed. Boundary vertices will have fixed values.
- max.iterations
Integer scalar, the maximum number of relaxation iterations to perform. Default is 100.
- tolerance
Numeric scalar, the convergence threshold for value changes. Default is 1e-6.
Value
A list containing:
harmonic_predictions: the numeric vector of smoothed values;converged: whether both the maximum update and discrete harmonic residual fell belowtolerance;num_region,num_boundary, andnum_interior: vertex counts for the requested region and its boundary/interior split;num_iterations: the number of relaxation iterations run;max_changeandmax_residual: per-iteration convergence diagnostics;status:converged,iteration_limit,no_boundary, orno_interior.
Details
Boundary vertices are exactly the region vertices with a neighbor outside the region. Degree-one vertices are not automatically boundary vertices. Boundary values and values outside the region remain fixed. Each synchronous relaxation step replaces interior values by neighbor averages with conductance \(1 / (w + 10^{-10})\), where \(w\) is the supplied edge length.
With no boundary, this function returns the input unchanged, with status
"no_boundary" and converged = FALSE. With no interior there
is nothing to solve: status is "no_interior" and convergence is true.
On a disconnected region, components without a connection to fixed boundary
values are not uniquely anchored; relaxation can oscillate. Inspect convergence
before using the result as a harmonic solution. Unlike this basic function,
harmonic.smoother() also runs relaxation when the whole region has no
boundary, retaining its historical behavior.
See also
harmonic.smoother for smoothing with topology tracking,
get.region.boundary for boundary vertex identification