degree_balance: Analyze Degree Balance of a Graph

View source: R/degree_balance.R

degree_balanceR Documentation

Analyze Degree Balance of a Graph

Description

Computes and summarizes vertex degree distributions for an igraph object. For directed graphs, the function reports in-degree and out-degree statistics, including their correlation and mean values. For undirected graphs, only overall degree statistics are reported.

Usage

degree_balance(g)

Arguments

g

An igraph graph object.

Details

If the graph is directed (see igraph::is_directed()), the function:

  • Computes in-degree and out-degree for each vertex.

  • Prints summary statistics for both distributions.

  • Reports the correlation between in-degree and out-degree.

  • Reports mean in-degree and mean out-degree.

If the graph is undirected, the function:

  • Computes the degree for each vertex.

  • Prints summary statistics of the degree distribution.

Value

A list containing:

  • out_degree Numeric vector of out-degrees (directed graphs only).

  • in_degree Numeric vector of in-degrees (directed graphs only).

  • degree Numeric vector of degrees (undirected graphs only).

Examples

library(igraph)
library(ig.degree.betweenness)

# Directed graph example
g_directed <- make_ring(10, directed = TRUE)
degree_balance(g_directed)

# Undirected graph example
g_undirected <- make_ring(10)
degree_balance(g_undirected)


ig.degree.betweenness documentation built on June 18, 2026, 1:06 a.m.