% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/network-utils.R
\name{filter_edges}
\alias{filter_edges}
\alias{subset_edges}
\title{Filter Edges by Metadata}
\usage{
filter_edges(
  x,
  ...,
  .keep_isolates = FALSE,
  keep_format = FALSE,
  directed = NULL
)

subset_edges(
  x,
  ...,
  .keep_isolates = FALSE,
  keep_format = FALSE,
  directed = NULL
)
}
\arguments{
\item{x}{Network input: cograph_network, matrix, igraph, network, or tna object.}

\item{...}{Filter expressions using any edge column (e.g., \code{weight > 0.5},
\code{weight > mean(weight)}, \code{abs(weight) > 0.3}).}

\item{.keep_isolates}{Logical. Keep nodes with no remaining edges? Default FALSE.}

\item{keep_format}{Logical. If TRUE, matrix, igraph, and statnet network
inputs are returned in that format. Default FALSE
returns cograph_network (universal format).}

\item{directed}{Logical or NULL. If NULL (default), auto-detect from matrix
symmetry. Set TRUE to force directed, FALSE to force undirected.
Only used for non-cograph_network inputs.}
}
\value{
A cograph_network object with filtered edges. If \code{keep_format = TRUE},
matrix, igraph, and statnet network inputs are converted back to that type.

See \code{\link{filter_edges}}.
}
\description{
Filter edges using dplyr-style expressions on any edge column. Returns a
cograph_network object by default (universal format), or optionally a
matrix, igraph, or statnet network object when \code{keep_format = TRUE}
and the input used one of those formats.
}
\examples{
adj <- matrix(c(0, .5, .8, 0, .5, 0, .3, .6,
                .8, .3, 0, .4, 0, .6, .4, 0), 4, 4, byrow = TRUE)
rownames(adj) <- colnames(adj) <- c("A", "B", "C", "D")

# Keep only strong edges
filter_edges(adj, weight > 0.5)

# Matrix in, matrix out
filter_edges(adj, weight > 0.5, keep_format = TRUE)

# Pipe-friendly with cograph_network
as_cograph(adj) |>
  filter_edges(weight > 0.3) |>
  filter_nodes(degree >= 2) |>
  splot()
}
\seealso{
\code{\link{filter_nodes}}, \code{\link{splot}}, \code{\link{subset_edges}}
}
