% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/update_graph_modules.R
\name{update_graph_modules2}
\alias{update_graph_modules2}
\title{Update module assignments from an existing column in graph object}
\usage{
update_graph_modules2(graph_obj, modules_new, levels = NULL)
}
\arguments{
\item{graph_obj}{A graph object returned by \code{build_graph_*()}.}

\item{modules_new}{Character. Name of an existing column in \code{graph_obj}
nodes whose values define the new module assignment. The column may or may
not contain \code{"Others"}.}

\item{levels}{Character vector. Optional explicit module order.
If \code{NULL}, order by module size (descending) and place
\code{"Others"} at the end when present.}
}
\value{
A new graph object with updated \code{Modularity}, \code{modularity2},
  and \code{modularity3} (and \code{modularity} if that column exists).
  All other node columns are preserved.
}
\description{
Uses the values of an existing node column as the new module assignment,
updating \code{Modularity}, \code{modularity2}, and \code{modularity3}
for seamless integration with \code{ggNetView()}. All other node columns
are preserved.
}
\examples{
data(ppi_example)
obj <- build_graph_from_df(
  df              = ppi_example$ppi,
  node_annotation = ppi_example$annotation
)
# Re-assign modularity from the existing `group` node column.
obj2 <- update_graph_modules2(graph_obj = obj, modules_new = "group")
levels(get_graph_nodes(obj2)$Modularity)
}
