% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/inject-nodespace.R
\name{inject_nodespace}
\alias{inject_nodespace}
\title{Dynamic Scale Injection for Edge Clipping}
\usage{
inject_nodespace(...)
}
\arguments{
\item{...}{Additional parameters passed to other methods (currently ignored).}
}
\value{
An object of class \code{inject_nodespace}, which interacts with the
ggplot2 \code{+} operator.
}
\description{
Utility function for \strong{RGraphSpace} that enables edge layers to scan
adjacent nodes and determine their dimensions. This information is used
to compute arrow clipping offsets, preventing edge geometry from
overlapping node symbols.
}
\details{
This function operates in two stages within the \code{ggplot2} workflow:
\enumerate{
\item \strong{Capture:} It scans the \code{plot} layers for a \link{GeomNodeSpace}
to extract both mapping variables (from \code{aes()}) and static parameters
(specifically \code{size} and \code{stroke}).
\item \strong{Injection:} It locates \link{GeomEdgeSpace} layers and injects
scale rules, captured mappings, and fixed parameters into the geometry
parameters.
}

This "lazy injection" calculates edge clipping based on the actual scales
used by the nodes, even if scales are defined after the layers.

\strong{Note:} \code{inject_nodespace()} must be called last in the \code{ggplot} chain to
allow the function to correctly scan all previously added layers and scales.
}
\examples{

library(igraph)
library(ggplot2)

# Generate a toy star graph
gtoy1 <- make_star(15, mode="out")

# Set node and edge attributes
V(gtoy1)$my_node_var <- runif(vcount(gtoy1), 1, 20)
E(gtoy1)$my_edge_var <-  runif(ecount(gtoy1), 1, 20)

# Create a GraphSpace object with a circular layout
gs <- GraphSpace(gtoy1, layout = layout_in_circle(gtoy1))

\dontrun{
# Build the plot
# Note that inject_nodespace() is called at the end to
# synchronize node sizes with edge clipping.
ggplot() +
  geom_edgespace(aes(colour = my_edge_var), data = gs) +
  geom_nodespace(aes(size = my_node_var), data = gs) +
  scale_size(range = c(2, 15)) +
  inject_nodespace()
}

}
\seealso{
\link{geom_edgespace}, \link{geom_nodespace}
}
