I know this is not a pure-coding question, but I wanted to try anyway, since it could lead to a coding answer!
Supposing I have a dataframe describing frequency of communication between nodes like the following that I turned into a directed network:
sender | receiver | frequency |
---|---|---|
a | b | 5 |
b | c | 7 |
c | a | 4 |
Now you can notice that the three nodes are connected and, if I make the network with graph_from_data_frame
then I would have that they are ALL connected and the only thing I can do to stress the fact that they are connected with different "weight" is by putting the frequency as E(g)$width
to show it in the plot.
What I want to know is:
Is there - and if yes, how - a way to perform descriptive statistics on this type of network (like centrality, betweennes, ecc..) ? Igraph counts only 1 edge for each node and the stats are kinda obvious.
library(igraph)
library(dplyr)
df1 <- data.frame(
stringsAsFactors = FALSE,
sender = c("a", "b", "c"),
receiver = c("b", "c", "a"),
frequency = c(5L, 7L, 4L)
)
# Rename frequency to weight
df2 <-
df1 |>
rename(weight = frequency)
# Create igraph object
g1 <-
graph_from_data_frame(df2)
# Calculate degree centrality
strength(g1)
#> a b c
#> 9 12 11
# Or you can specify frequency using the weight argument
df1 |>
graph_from_data_frame() |>
strength(weights = df1$frequency)
#> a b c
#> 9 12 11