% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/get_node_centrality.R
\name{get_node_centrality}
\alias{get_node_centrality}
\title{Compute per-node centralities and attach them to a graph object}
\usage{
get_node_centrality(
  graph_obj,
  measures = c("Betweenness", "Closeness", "Eigenvector", "PageRank", "Hub_score",
    "Authority_score", "Coreness", "Harmonic"),
  weighted = FALSE,
  overwrite = TRUE
)
}
\arguments{
\item{graph_obj}{A `tbl_graph` produced by any
`build_graph_from_*()` constructor.}

\item{measures}{Character vector. Which centralities to compute.
Pass `"all"` to compute every supported measure. Defaults to all
eight measures listed in \strong{Available measures}.}

\item{weighted}{Logical (default `FALSE`). If `TRUE`, the edge
`weight` attribute is used as a distance (`igraph` convention:
higher weight = farther). Because correlation networks have
`weight = |correlation|` -- where higher means *closer* -- the
distance used internally is `1 / weight` so that strongly
correlated pairs count as short paths. Set `FALSE` (default) for
the textbook unweighted versions.}

\item{overwrite}{Logical (default `TRUE`). If a measure column
already exists on the input graph, controls whether to overwrite
it (silent overwrite when `TRUE`; warning + skip when `FALSE`).}
}
\value{
A `tbl_graph` whose node table is augmented with one column
  per requested measure (using the column names listed in
  \strong{Available measures}). Other vertex / edge columns are
  preserved verbatim.
}
\description{
Computes a panel of standard per-node centrality measures and adds
them as new vertex columns on the input `tbl_graph`. Use this for
node-importance analysis when you want to rank nodes (or map a
centrality to a visual aesthetic in [ggNetView()]) by something more
informative than degree alone.
}
\details{
Note that [get_network_topology()] reports the same families of
metrics but as **network-level summaries** (a single mean / sum per
network). `get_node_centrality()` is the per-node counterpart -- it
keeps every individual value so you can sort, rank, threshold, or
colour by it.
}
\section{Available measures}{

All measures wrap the corresponding `igraph` function:
\describe{
  \item{`"Betweenness"`}{Number of shortest paths through each node
    (`igraph::betweenness`).}
  \item{`"Closeness"`}{Inverse mean shortest-path distance from a
    node to every other node (`igraph::closeness`, `mode = "all"`).
    Returns `NaN` for nodes in their own connected component when
    the component is a singleton.}
  \item{`"Eigenvector"`}{Eigenvector centrality
    (`igraph::eigen_centrality`).}
  \item{`"PageRank"`}{Google PageRank score (`igraph::page_rank`).}
  \item{`"Hub_score"`}{HITS hub score
    (`igraph::hub_score`).}
  \item{`"Authority_score"`}{HITS authority score
    (`igraph::authority_score`).}
  \item{`"Coreness"`}{k-core membership of each vertex
    (`igraph::coreness`).}
  \item{`"Harmonic"`}{Harmonic centrality
    (`igraph::harmonic_centrality`); robust to disconnected graphs
    where Closeness becomes ill-defined.}
}
}

\examples{
\donttest{
set.seed(1)
mat <- matrix(stats::rnorm(40 * 20), nrow = 40, ncol = 20)
rownames(mat) <- paste0("feature", seq_len(40))
colnames(mat) <- paste0("sample",  seq_len(20))
obj <- build_graph_from_mat(
  mat = mat, method = "cor", cor.method = "pearson",
  proc = "none", r.threshold = 0.3, p.threshold = 0.05
)

obj_aug <- get_node_centrality(obj)
obj_aug \%>\%
  tidygraph::activate(nodes) \%>\%
  tidygraph::as_tibble() \%>\%
  dplyr::arrange(dplyr::desc(Betweenness)) \%>\%
  utils::head(5)
}
}
\seealso{
[get_network_topology()] for network-level summaries of
  the same metrics; [get_node_ivi()] for an integrative
  importance score that combines local, semi-local, and global
  centralities.
}
