View source: R/network-summary.R
| degree_distribution | R Documentation |
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.
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",
...
)
x |
Network input: matrix, igraph, network, cograph_network, or tna object. |
mode |
For directed networks: "all", "in", or "out". Default "all". |
directed |
Logical or NULL. If NULL (default), auto-detect from matrix symmetry. Set TRUE to force directed, FALSE to force undirected. |
loops |
Logical. If TRUE (default), keep self-loops. Set FALSE to remove them. |
simplify |
How to combine multiple edges between the same node pair. Options: "sum" (default), "mean", "max", "min", or FALSE/"none" to keep multiple edges. |
cumulative |
Logical. If TRUE, show CCDF (complementary cumulative distribution: P(degree >= k)) instead of frequency. Default FALSE. |
breaks |
Bin specification passed to |
bins |
Integer. Approximate number of bins. Overrides |
bin_width |
Numeric. Width of each bin. Default NULL (auto: 1 when the
degree range is |
normalize |
Logical. If TRUE, the y-axis shows proportions (bars sum to 1) instead of counts. Default FALSE. |
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). |
main |
Character. Plot title. Default "Degree Distribution". |
xlab |
Character. X-axis label. Default "Degree". |
ylab |
Character. Y-axis label. Default auto-chosen based on
|
col |
Character. Bar/line fill color. Default "steelblue". |
border |
Character. Bar border color. Default "white". |
... |
Additional graphical arguments passed to
|
Invisibly returns a list with components:
Named numeric vector of per-node degrees.
Table of degree frequencies.
Breakpoints used for the histogram (non-cumulative only).
Bin counts (non-cumulative only).
Bin proportions (non-cumulative only).
# 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.