% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/network-summary.R
\name{degree_distribution}
\alias{degree_distribution}
\title{Degree Distribution Visualization}
\usage{
degree_distribution(
  x,
  mode = "all",
  directed = NULL,
  loops = TRUE,
  simplify = "sum",
  cumulative = FALSE,
  breaks = NULL,
  bins = NULL,
  bin_width = NULL,
  normalize = FALSE,
  log = "",
  main = "Degree Distribution",
  xlab = "Degree",
  ylab = NULL,
  col = "steelblue",
  border = "white",
  ...
)
}
\arguments{
\item{x}{Network input: matrix, igraph, network, cograph_network, or tna
object.}

\item{mode}{For directed networks: "all", "in", or "out". Default "all".}

\item{directed}{Logical or NULL. If NULL (default), auto-detect from matrix
symmetry. Set TRUE to force directed, FALSE to force undirected.}

\item{loops}{Logical. If TRUE (default), keep self-loops. Set FALSE to
remove them.}

\item{simplify}{How to combine multiple edges between the same node pair.
Options: "sum" (default), "mean", "max", "min", or FALSE/"none" to keep
multiple edges.}

\item{cumulative}{Logical. If TRUE, show CCDF (complementary cumulative
distribution: P(degree >= k)) instead of frequency. Default FALSE.}

\item{breaks}{Bin specification passed to \code{\link[graphics]{hist}}. Can
be a numeric vector of breakpoints, a single number giving the number of
bins, or a character string naming an algorithm (e.g. "Sturges", "FD",
"scott"). Overrides \code{bins} and \code{bin_width}. Default NULL
(auto-detect).}

\item{bins}{Integer. Approximate number of bins. Overrides \code{bin_width}.
Default NULL.}

\item{bin_width}{Numeric. Width of each bin. Default NULL (auto: 1 when the
degree range is \eqn{\le 50}{<= 50}, otherwise Freedman-Diaconis).}

\item{normalize}{Logical. If TRUE, the y-axis shows proportions (bars sum
to 1) instead of counts. Default FALSE.}

\item{log}{Character. Axis log-scaling: "" (none, default), "x", "y", or
"xy". Histogram plots apply y-axis log scaling for "y" or "xy";
cumulative plots support x, y, and xy scaling, with "xy" producing a
log-log CCDF (standard for power-law inspection).}

\item{main}{Character. Plot title. Default "Degree Distribution".}

\item{xlab}{Character. X-axis label. Default "Degree".}

\item{ylab}{Character. Y-axis label. Default auto-chosen based on
\code{normalize} and \code{cumulative}.}

\item{col}{Character. Bar/line fill color. Default "steelblue".}

\item{border}{Character. Bar border color. Default "white".}

\item{...}{Additional graphical arguments passed to
\code{\link[graphics]{barplot}} (histogram) or
\code{\link[graphics]{plot}} (cumulative).}
}
\value{
Invisibly returns a list with components:
\describe{
\item{degree}{Named numeric vector of per-node degrees.}
\item{table}{Table of degree frequencies.}
\item{breaks}{Breakpoints used for the histogram (non-cumulative only).}
\item{counts}{Bin counts (non-cumulative only).}
\item{proportions}{Bin proportions (non-cumulative only).}
}
}
\description{
Creates a histogram or cumulative distribution plot of node degrees. By
default, bins are integer-aligned (one bar per degree value) so each bar
maps to an exact degree.
}
\examples{
# Undirected network
adj <- matrix(c(0, 1, 1, 0, 1, 0, 1, 1,
                1, 1, 0, 1, 0, 1, 1, 0), 4, 4, byrow = TRUE)
cograph::degree_distribution(adj)
cograph::degree_distribution(adj, cumulative = TRUE)

# Directed network, in-degree
directed_adj <- matrix(c(0, 1, 0, 0, 0, 0, 1, 0,
                         1, 0, 0, 1, 0, 1, 0, 0), 4, 4, byrow = TRUE)
cograph::degree_distribution(directed_adj, mode = "in")
}
