% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/communities.R
\name{community_leiden}
\alias{community_leiden}
\alias{com_ld}
\title{Leiden Community Detection}
\usage{
community_leiden(
  x,
  weights = NULL,
  resolution = 1,
  objective_function = c("CPM", "modularity"),
  beta = 0.01,
  initial_membership = NULL,
  n_iterations = 2,
  vertex_weights = NULL,
  seed = NULL,
  ...
)

com_ld(
  x,
  weights = NULL,
  resolution = 1,
  objective_function = c("CPM", "modularity"),
  beta = 0.01,
  initial_membership = NULL,
  n_iterations = 2,
  vertex_weights = NULL,
  seed = NULL,
  ...
)
}
\arguments{
\item{x}{Network input}

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

\item{resolution}{Resolution parameter. Default 1.}

\item{objective_function}{Optimization objective: "CPM" (Constant Potts Model)
or "modularity". Default "CPM".}

\item{beta}{Parameter for randomness in refinement step. Default 0.01.}

\item{initial_membership}{Initial community assignments (optional).}

\item{n_iterations}{Number of iterations. Default 2. Use -1 for convergence.}

\item{vertex_weights}{Vertex weights for CPM objective.}

\item{seed}{Random seed for reproducibility. Default NULL.}

\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{
Leiden algorithm - an improved version of Louvain that guarantees
well-connected communities. Supports CPM and modularity objectives.
}
\examples{
if (requireNamespace("igraph", quietly = TRUE)) {
  g <- igraph::make_graph("Zachary")

  # Standard Leiden
  comm <- community_leiden(g)

  # Higher resolution for more communities
  comm2 <- community_leiden(g, resolution = 1.5)

  # Modularity objective
  comm3 <- community_leiden(g, objective_function = "modularity")
}
}
\references{
Traag, V.A., Waltman, L., & van Eck, N.J. (2019).
From Louvain to Leiden: guaranteeing well-connected communities.
\emph{Scientific Reports}, 9, 5233.
}
