7

I am trying to learn few basic functions in Igraph- But, I am having problems computing the degrees from a gragph: see example below (I copied the following example from this site):

Example of data set:

edges <- matrix(c(103, 86, 24, 103, 103, 2, 92, 103, 87, 103, 103, 101, 103, 44), ncol=2, byrow=T)

Create graph

g <- graph(as.vector(t(edges)))

I can compute the degrees from the matrix edges: degree(edges) [1] 378 254 210 390 380 408 294 1230 1084

But I cannot compute the degrees from the graph g:

degree(g)

I am getting the following error:

Error in FUN(X[[1L]], ...) : as.edgelist.sna input must be an adjacency matrix/array, edgelist matrix, network, or sparse matrix, or list thereof.

Anyone knows why I am getting this error?

Ibrahima
  • 71
  • 1
  • 2

2 Answers2

5

So what happened here is igraph::degree is masked by sna::degree. Just use:

igraph::degree

and it should work

2

I ran into same issue. This worked for me:

net <- make_ring(10)
deg <- centralization.degree(net)$res
josliber
  • 43,891
  • 12
  • 98
  • 133
inivri
  • 29
  • 5