% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/communities.R
\name{community_label_propagation}
\alias{community_label_propagation}
\alias{com_lp}
\title{Label Propagation Community Detection}
\usage{
community_label_propagation(
  x,
  weights = NULL,
  mode = c("out", "in", "all"),
  initial = NULL,
  fixed = NULL,
  seed = NULL,
  ...
)

com_lp(
  x,
  weights = NULL,
  mode = c("out", "in", "all"),
  initial = NULL,
  fixed = NULL,
  seed = NULL,
  ...
)
}
\arguments{
\item{x}{Network input}

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

\item{mode}{For directed graphs: "out" (default), "in", or "all".}

\item{initial}{Initial labels (integer vector or NULL for unique labels).}

\item{fixed}{Logical vector indicating which labels are fixed.}

\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{
Fast semi-synchronous label propagation algorithm.
Each node adopts the most frequent label among its neighbors.
}
\examples{
if (requireNamespace("igraph", quietly = TRUE)) {
  g <- igraph::make_graph("Zachary")

  # Basic label propagation
  comm <- community_label_propagation(g)

  # With some nodes fixed to specific communities
  initial <- rep(NA, igraph::vcount(g))
  initial[1] <- 1  # Node 1 in community 1
  initial[34] <- 2 # Node 34 in community 2
  fixed <- !is.na(initial)
  initial[is.na(initial)] <- seq_len(sum(is.na(initial)))
  comm2 <- community_label_propagation(g, initial = initial, fixed = fixed)
}
\dontshow{if (requireNamespace("igraph", quietly = TRUE)) withAutoprint(\{ # examplesIf}
net <- as_cograph(matrix(runif(25), 5, 5))
com_lp(net)
\dontshow{\}) # examplesIf}
}
\references{
Raghavan, U.N., Albert, R., & Kumara, S. (2007).
Near linear time algorithm to detect community structures in large-scale networks.
\emph{Physical Review E}, 76, 036106.
}
