cgv_layout_fr_bh: Barnes-Hut Fruchterman-Reingold Layout (3D, fast)

View source: R/layout.R

cgv_layout_fr_bhR Documentation

Barnes-Hut Fruchterman-Reingold Layout (3D, fast)

Description

Same energy model as cgv_layout_fr but with O(n log n) repulsion approximated through an octree. Suitable for large graphs (10^4+ nodes).

Usage

cgv_layout_fr_bh(
  n_nodes,
  edges,
  n_iter = 200L,
  ideal_len = NULL,
  theta = 1,
  cool = 0.98,
  min_dist = 0.01,
  seed = NULL,
  init = NULL,
  normalize = TRUE
)

Arguments

n_nodes

Integer. Number of nodes.

edges

Two-column integer matrix (from, to), 1-based.

n_iter

Integer. Number of iterations (default 200).

ideal_len

Numeric target edge length. If NULL, defaults to n_nodes^(1/3) * 0.8.

theta

Barnes-Hut opening angle (default 1.0). Larger = faster, less accurate.

cool

Per-iteration temperature decay (default 0.98).

min_dist

Minimum distance clamp for repulsion / edge attraction (default 0.01). Avoids division-by-zero when nodes coincide.

seed

Optional integer for reproducible initialization.

init

Optional n_nodes x 3 matrix of initial positions. If NULL, uses rnorm.

normalize

Logical. If TRUE, recenters and scales output to [-15, 15]. Default TRUE.

Value

Numeric matrix n_nodes x 3 of node coordinates.


cgvR documentation built on May 12, 2026, 1:06 a.m.