calc_centrality: Compute Centrality for a Weighted/Unweighted Network

View source: R/svdcentrality.R

calc_centralityR Documentation

Compute Centrality for a Weighted/Unweighted Network

Description

This function calculates the centrality of species in a network based on an adjacency matrix or igraph object using a specified centrality measure.

Usage

calc_centrality(A, centrality_func = eigen_centrality)

Arguments

A

An igraph object or an adjacency matrix. The values represent interaction strengths.

centrality_func

A function to compute centrality. Default is eigen_centrality. Other options: page_rank, betweenness, degree, etc.

Value

A list containing:

CentralityScores

A data frame with species names and their centrality scores.

Plot_Centrality

A ggplot object showing the top 10 species by centrality.

Examples

# Example usage with an adjacency matrix A
results <- calc_centrality(A, centrality_func = page_rank)
print(results$CentralityScores)
print(results$Plot_Centrality)


lsaravia/EcoNetwork documentation built on April 5, 2025, 1:51 p.m.