% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cluster-metrics.R
\name{summarize_network}
\alias{summarize_network}
\alias{cluster_network}
\alias{cnet}
\title{Summarize Network by Clusters}
\usage{
summarize_network(
  x,
  cluster_list = NULL,
  method = c("sum", "mean", "max", "min", "median", "density", "geomean"),
  directed = TRUE
)

cluster_network(
  x,
  cluster_list = NULL,
  method = c("sum", "mean", "max", "min", "median", "density", "geomean"),
  directed = TRUE
)

cnet(
  x,
  cluster_list = NULL,
  method = c("sum", "mean", "max", "min", "median", "density", "geomean"),
  directed = TRUE
)
}
\arguments{
\item{x}{A weight matrix, tna object, or cograph_network.}

\item{cluster_list}{Cluster specification:
\itemize{
\item Named list of node vectors (e.g., \code{list(A = c("n1", "n2"), B = c("n3", "n4"))})
\item String column name from nodes data (e.g., "clusters", "groups")
\item NULL to auto-detect from common column names
}}

\item{method}{Aggregation method for edge weights: "sum", "mean", "max",
"min", "median", "density", "geomean". Default "sum".}

\item{directed}{Logical. Treat network as directed. Default TRUE.}
}
\value{
A cograph_network object with:
\itemize{
\item One node per cluster (named by cluster)
\item Edge weights = aggregated between-cluster weights
\item nodes$size = cluster sizes (number of original nodes)
}

See \code{\link{summarize_network}}.

See \code{\link{summarize_network}}.
}
\description{
Creates a summary network where each cluster becomes a single node.
Edge weights are aggregated from the original network using the specified
method. Returns a cograph_network object ready for plotting.
}
\examples{
# Create a network with clusters
mat <- matrix(runif(100), 10, 10)
diag(mat) <- 0
rownames(mat) <- colnames(mat) <- LETTERS[1:10]

# Define clusters
clusters <- list(
  Group1 = c("A", "B", "C"),
  Group2 = c("D", "E", "F"),
  Group3 = c("G", "H", "I", "J")
)

# Create summary network
summary_net <- summarize_network(mat, clusters)
splot(summary_net)

# With cograph_network (auto-detect clusters column)
Net <- cograph(mat)
Net$nodes$clusters <- rep(c("A", "B", "C"), c(3, 3, 4))
summary_net <- summarize_network(Net)  # Auto-detects 'clusters'
}
\seealso{
\code{\link{cluster_summary}}, \code{\link{plot_mcml}}
}
