Skip to contents

For each node, compares the number of friends (degree) to the mean number of friends among their neighbors. Calculates the proportion of nodes that have fewer friends than the average of their friends (the friendship paradox).

Usage

compare_friendship_paradox(graph, return_node_data = FALSE)

Arguments

graph

An igraph or tidygraph::tbl_graph object representing an undirected network.

return_node_data

Logical. If TRUE, includes a data frame with node-level results.

Value

A list with:

  • paradox_proportion: Proportion of nodes experiencing the friendship paradox

  • summary: A data frame with average degree and average neighbor degree

  • nodes: (Optional) A data frame with node-level metrics if return_node_data = TRUE

Details

Supports both igraph and tidygraph::tbl_graph inputs.

Examples

if (FALSE) { # \dontrun{
# Use with an igraph network
library(igraph)
g_ig <- simulate_feld_1991()
compare_friendship_paradox(g_ig)

# Return node-level metrics too
result2 <- compare_friendship_paradox(g, return_node_data = TRUE)
head(result2$nodes)
} # }