% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/layout.R
\name{cgv_layout_fr}
\alias{cgv_layout_fr}
\title{Fruchterman-Reingold Force-Directed Layout}
\usage{
cgv_layout_fr(
  n_nodes,
  edges,
  n_iter = 300L,
  ideal_len = NULL,
  dim = 3L,
  seed = NULL,
  init = NULL,
  cool = 0.98,
  normalize = TRUE,
  verbose = FALSE
)
}
\arguments{
\item{n_nodes}{Integer. Number of nodes.}

\item{edges}{Two-column integer matrix \code{(from, to)}, 1-based. Direction
is ignored (forces are symmetric).}

\item{n_iter}{Integer. Number of iterations (default 300).}

\item{ideal_len}{Numeric. Target edge length. If \code{NULL}, defaults to
\code{n_nodes^(1/dim) * 0.8}.}

\item{dim}{Integer, 2 or 3. Output dimensionality (default 3).}

\item{seed}{Optional integer for reproducible initialization.}

\item{init}{Optional \code{n_nodes x dim} matrix of initial positions.
If \code{NULL}, uses \code{rnorm}.}

\item{cool}{Numeric in (0, 1]. Per-iteration temperature decay (default 0.98).}

\item{normalize}{Logical. If \code{TRUE}, recenters and scales output to
fit in \code{[-15, 15]} (matches the demos' camera setup). Default \code{TRUE}.}

\item{verbose}{Logical. Print progress every 50 iterations.}
}
\value{
Numeric matrix \code{n_nodes x dim} of node coordinates.
}
\description{
Computes 3D (or 2D) node positions so that connected nodes settle at
approximately equal distance \code{ideal_len}, while non-adjacent nodes
repel each other. Implements the Fruchterman-Reingold algorithm with
linearly-cooling temperature, fully vectorized over nodes and edges.
}
\examples{
edges <- cbind(c(1, 2, 3, 4), c(2, 3, 4, 1))
pos <- cgv_layout_fr(4, edges, n_iter = 200)
}
