invert_weights: Invert Edge Weights (Similarity to Distance and Back)

View source: R/wrangle-weights.R

invert_weightsR Documentation

Invert Edge Weights (Similarity to Distance and Back)

Description

Turns strong ties into short distances. Path-based measures treat weights as costs, so similarity weights are inverted before such measures are computed.

Usage

invert_weights(
  x,
  method = c("reciprocal", "max_minus", "reflect"),
  keep_format = FALSE,
  directed = NULL
)

Arguments

x

Network input.

method

How to invert:

"reciprocal"

(default) 1 / w, the standard similarity-to-distance map.

"max_minus"

max(w) - w. The strongest edge becomes zero and is therefore dropped; a cograph_edges_dropped warning says how many.

"reflect"

max(w) + min(w) - w. Reverses the order of the weights and keeps every edge when all weights are positive.

keep_format

Logical. Return the input format when TRUE.

directed

Logical or NULL. If NULL (default), auto-detect.

Value

A cograph_network with inverted weights, or the input format when keep_format = TRUE.

See Also

normalize_weights, shortest_paths

Examples

invert_weights(regulation_net, method = "reciprocal")

cograph documentation built on Nov. 19, 2026, 5:07 p.m.