% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/network-utils.R
\name{color_communities}
\alias{color_communities}
\title{Color Nodes by Community}
\usage{
color_communities(x, method = "louvain", palette = NULL, ...)
}
\arguments{
\item{x}{Network input: matrix, igraph, network, cograph_network, or tna object.}

\item{method}{Community detection algorithm. See \code{\link{detect_communities}}
for available methods. Default \code{"louvain"}.}

\item{palette}{Color palette to use. Can be:
\itemize{
\item \code{NULL} (default): Uses a colorblind-friendly palette
\item A character vector of colors
\item A function that takes n and returns n colors
\item A palette name: "rainbow", "colorblind", "pastel", "viridis"
}}

\item{...}{Additional arguments passed to \code{\link{detect_communities}}.}
}
\value{
A named character vector of colors (one per node), suitable for
use with \code{splot()} \code{node_fill} parameter.
}
\description{
Generate colors for nodes based on community membership. Designed for
direct use with \code{splot()} \code{node_fill} parameter.
}
\examples{
adj <- matrix(c(0, .5, .8, 0,
                .5, 0, .3, .6,
                .8, .3, 0, .4,
                 0, .6, .4, 0), 4, 4, byrow = TRUE)
rownames(adj) <- colnames(adj) <- c("A", "B", "C", "D")

# Basic usage with splot
splot(adj, node_fill = color_communities(adj))

# Custom palette
splot(adj, node_fill = color_communities(adj, palette = c("red", "blue")))
}
\seealso{
\code{\link{detect_communities}}, \code{\link{splot}}
}
