Skip to contents

Plots each node's number of friends (degree) against the mean number of friends among their friends (mean neighbor degree), with a 1:1 reference line. Useful for visualizing the strength and spread of the friendship paradox.

Usage

plot_friendship_paradox(graph, label = FALSE, point_size = 2, ...)

Arguments

graph

An igraph or tidygraph::tbl_graph object.

label

Logical. If TRUE, adds node labels.

point_size

Size of points in the scatterplot.

...

Additional arguments passed to ggplot2::geom_point().

Value

A ggplot2 object.

Examples

library(tidygraph)
#> 
#> Attaching package: ‘tidygraph’
#> The following object is masked from ‘package:igraph’:
#> 
#>     groups
#> The following object is masked from ‘package:stats’:
#> 
#>     filter
library(ggplot2)

g <- simulate_feld_1991_tbl()
#> Error in simulate_feld_1991_tbl(): could not find function "simulate_feld_1991_tbl"
plot_friendship_paradox(g)
#> Error: object 'g' not found