ox_centrality: Node centrality

View source: R/metrics.R

ox_centralityR Documentation

Node centrality

Description

Computes betweenness and/or closeness centrality for every node, using the Rust core (Brandes' algorithm for betweenness; one Dijkstra per node for closeness).

Usage

ox_centrality(
  g,
  type = c("betweenness", "closeness"),
  weight = "length",
  normalized = TRUE
)

Arguments

g

An osm_graph.

type

Centrality measures to compute: any of "betweenness" and "closeness". Default both.

weight

Edge column used as weight. Default "length".

normalized

Scale scores for comparability across graphs. Betweenness is divided by (n - 1)(n - 2); closeness uses the Wasserman–Faust correction for disconnected graphs. Default TRUE.

Value

A tibble with column osmid plus one column per requested measure.

Examples

g <- example_osm_graph(n = 4)
ox_centrality(g, type = "betweenness")

osmnxr documentation built on Oct. 20, 2026, 1:07 a.m.