
Compare Friendship Paradox in a Network
compare_friendship_paradox.Rd
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).
Arguments
- graph
An
igraph
ortidygraph::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 paradoxsummary
: A data frame with average degree and average neighbor degreenodes
: (Optional) A data frame with node-level metrics ifreturn_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)
} # }