Unified edge width scaling function that supports multiple scaling modes, two-tier cutoff system (like qgraph), and output range specification.
scale_edge_widths(
weights,
esize = NULL,
n_nodes = NULL,
directed = FALSE,
mode = "linear",
maximum = NULL,
minimum = 0,
cut = NULL,
range = c(0.5, 4)
)Numeric vector of scaled edge widths.
Numeric vector of edge weights.
Base edge size. NULL uses adaptive sizing based on n_nodes.
Number of nodes (for adaptive esize calculation).
Whether network is directed (affects adaptive esize).
Scaling mode: "linear", "log", "sqrt", or "rank".
Max weight for normalization. NULL for auto-detect.
Min weight threshold. Edges below this get minimum width.
Two-tier cutoff threshold. NULL = auto (75th percentile), 0 = disabled (continuous scaling), positive number = manual threshold.
Output width range as c(min_width, max_width).
linear (default): Direct proportional scaling, matches qgraph behavior.
log: Logarithmic scaling for wide weight ranges. Uses log1p for stability.
sqrt: Square root scaling for moderate compression.
rank: Rank-based scaling for equal visual spacing regardless of weight distribution.
When cut > 0, edges are divided into two tiers:
Below cut: Minimal width variation (20% of range)
Above cut: Full width scaling (80% of range)
This matches qgraph's behavior where weak edges are visually de-emphasized.