0

I have network data with directed and valued ties between nodes. I need to compute the in-degree for the nodes and use the "degree"-function in the "sna"-package of R, but it ignores the valued data and produce results as if the data was unvalued/binary. Here is a reproducible example:

TestData:

  Ego   Alter Strength
  <chr> <chr>    <num>
1 1     2         0.39
2 1     5         0.04
3 2     3         0.29
4 2     5         0.39
5 3     1         0.29
6 3     4         0.29
7 4     1         0.14
8 4     2         0.14
9 5     1         0.21

Script:

#Load packages "igraph", "sna", "ggplot2" and "ggraph"
library(igraph)
library(ggplot2)
library(ggraph)
library(intergraph)
library(sna)

#Create graph object with TestData dataframe
graphTestData <- graph_from_data_frame(TestData, directed = TRUE)

#Visualize network with tie strength as edge width
ggraph(graphTestData) + 
  geom_edge_link2(aes(width = Strength), arrow = arrow(length = unit(3, "mm")), show.legend = FALSE) +
  scale_edge_width(range = c(0.1, 1)) +
  geom_node_point(size=3)

#Transform igraph object to network object
networkTestData <- asNetwork(graphTestData)

#Compute in-degree for the nodes in the TestData-network
indegreeTestData <- degree(networkTestData, g=1, gmode="digraph", diag=FALSE, tmaxdev=FALSE, cmode="indegree", rescale=FALSE, ignore.eval=FALSE)

#View resulting in-degrees
View(indegreeTestData)

The network visualization clearly demonstrates valued ties, but the in-degrees for the nodes are clearly not using the valued data as specified by "ignore.eval=FALSE" and is distributed as follows: 1=3, 2=2, 3=1, 4=1, 5=2

What am I doing wrong? Please help!

Visualization of network that demonstrates valued ties

Szabolcs
  • 24,728
  • 9
  • 85
  • 174
Per Becker
  • 21
  • 1

0 Answers0