% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pairwise.R
\name{pairwise_edges}
\alias{pairwise_edges}
\alias{relatedness_edges_from_kinship}
\alias{spatial_edges_from_coords}
\title{Build Pairwise Leakage Edges from Continuous Similarity}
\usage{
relatedness_edges_from_kinship(
  pairs,
  threshold,
  id1 = "id1",
  id2 = "id2",
  kinship = "kinship"
)

spatial_edges_from_coords(coords, radius, id = "sample_id", coord_cols = NULL)
}
\arguments{
\item{pairs}{A data.frame of subject pairs with two id columns and a metric
column.}

\item{threshold}{Minimum kinship value (inclusive) for a pair to be kept.}

\item{id1, id2}{Column names in \code{pairs} holding the two subject ids.}

\item{kinship}{Column name in \code{pairs} holding the kinship / relatedness
value.}

\item{coords}{A data.frame with one row per sample: a sample id column plus
the numeric coordinate columns.}

\item{radius}{Maximum distance (inclusive) for two samples to be adjacent.}

\item{id}{Column name in \code{coords} holding the sample id.}

\item{coord_cols}{Character vector of coordinate columns in \code{coords}.
Defaults to every numeric column other than \code{id}.}
}
\value{
A \code{graph_edge_set}.
}
\description{
Helpers that turn a continuous, pairwise similarity signal into the
thresholded, undirected edges consumed by
\code{derive_split_constraints(mode = "relatedness")} and
\code{derive_split_constraints(mode = "spatial")}. Only pairs that pass the
threshold become edges; the derivation modes then form groups as connected
components over those edges (transitive closure), so a chain of individually
below-radius neighbours can still land in one group.
}
\details{
\code{relatedness_edges_from_kinship()} keeps subject pairs whose kinship (or
relatedness) coefficient is \emph{at least} \code{threshold} and emits
\code{subject_related_to} edges (\code{Subject} -> \code{Subject}).

\code{spatial_edges_from_coords()} keeps sample pairs whose Euclidean
distance over the coordinate columns is \emph{at most} \code{radius} and
emits \code{sample_adjacent_to} edges (\code{Sample} -> \code{Sample}).

Both return a \code{graph_edge_set} that can be combined with the other node
and edge sets in \code{build_dependency_graph()}. The passing metric value is
carried on each edge as an attribute (\code{kinship} / \code{distance}).
}
\examples{
pairs <- data.frame(
  id1 = c("P1", "P1", "P2"),
  id2 = c("P2", "P3", "P3"),
  kinship = c(0.25, 0.02, 0.30)
)
relatedness_edges_from_kinship(pairs, threshold = 0.1)

coords <- data.frame(
  sample_id = c("S1", "S2", "S3"),
  x = c(0, 1, 9),
  y = c(0, 1, 9)
)
spatial_edges_from_coords(coords, radius = 2)
}
