% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/communities.R
\name{community_optimal}
\alias{community_optimal}
\alias{com_op}
\title{Optimal Community Detection}
\usage{
community_optimal(x, weights = NULL, ...)

com_op(x, weights = NULL, ...)
}
\arguments{
\item{x}{Network input}

\item{weights}{Edge weights. NULL uses network weights, NA for unweighted.}

\item{...}{Additional arguments passed to \code{\link{to_igraph}}}
}
\value{
A \code{cograph_communities} object

A \code{cograph_communities} object. See \code{\link{detect_communities}}.
}
\description{
Finds the optimal community structure by maximizing modularity exactly.
Very slow - only use for small networks (<50 nodes).
}
\note{
This is an NP-hard problem. Use only for tiny networks.
}
\examples{
\dontshow{if (requireNamespace("igraph", quietly = TRUE)) withAutoprint(\{ # examplesIf}
g <- igraph::make_ring(10)
comm <- community_optimal(g)
membership(comm)
\dontshow{\}) # examplesIf}
\dontshow{if (requireNamespace("igraph", quietly = TRUE)) withAutoprint(\{ # examplesIf}
net <- as_cograph(matrix(runif(25), 5, 5))
com_op(net)
\dontshow{\}) # examplesIf}
}
\references{
Brandes, U., Delling, D., Gaertler, M., Gorke, R., Hoefer, M.,
Nikoloski, Z., & Wagner, D. (2008).
On modularity clustering.
\emph{IEEE Transactions on Knowledge and Data Engineering}, 20(2), 172-188.
}
