% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simplify.R
\name{simplify}
\alias{simplify}
\alias{simplify.matrix}
\alias{simplify.cograph_network}
\alias{simplify.igraph}
\alias{simplify.tna}
\alias{simplify.default}
\title{Simplify a Network}
\usage{
simplify(x, remove_loops, remove_multiple, edge_attr_comb, ...)

\method{simplify}{matrix}(
  x,
  remove_loops = TRUE,
  remove_multiple = TRUE,
  edge_attr_comb = "mean",
  ...
)

\method{simplify}{cograph_network}(
  x,
  remove_loops = TRUE,
  remove_multiple = TRUE,
  edge_attr_comb = "mean",
  ...
)

\method{simplify}{igraph}(
  x,
  remove_loops = TRUE,
  remove_multiple = TRUE,
  edge_attr_comb = "mean",
  ...
)

\method{simplify}{tna}(
  x,
  remove_loops = TRUE,
  remove_multiple = TRUE,
  edge_attr_comb = "mean",
  ...
)

\method{simplify}{default}(
  x,
  remove_loops = TRUE,
  remove_multiple = TRUE,
  edge_attr_comb = "mean",
  ...
)
}
\arguments{
\item{x}{Network input (matrix, cograph_network, igraph, tna object).}

\item{remove_loops}{Logical. Remove self-loops (diagonal entries)?}

\item{remove_multiple}{Logical. Merge duplicate edges?}

\item{edge_attr_comb}{How to combine weights of duplicate edges:
\code{"sum"}, \code{"mean"}, \code{"max"}, \code{"min"},
\code{"first"}, or a custom function.}

\item{...}{Additional arguments (currently unused).}
}
\value{
The simplified network in the same format as the input.
}
\description{
Removes self-loops and merges duplicate (multi-)edges, similar to
\code{igraph::simplify()}. Works on matrices, cograph_network, igraph,
and tna objects.
}
\examples{
# Matrix with self-loops
mat <- matrix(c(0.5, 0.3, 0, 0.3, 0.2, 0.4, 0, 0.4, 0.1), 3, 3)
rownames(mat) <- colnames(mat) <- c("A", "B", "C")
simplify(mat)

# Edge list with duplicates
edges <- data.frame(from = c(1, 1, 2), to = c(2, 2, 3), weight = c(0.3, 0.7, 0.5))
net <- cograph(edges, layout = NULL)
simplify(net)
simplify(net, edge_attr_comb = "sum")
}
\seealso{
\code{\link{filter_edges}} for conditional edge removal,
\code{\link{centrality}} which has its own \code{simplify} parameter
}
