I have a network in the form of an adjacency matrix, and I am trying to create a plot that shows the degree distribution of the network.
First of all, I used the function "graph.adjacency" to create an igraph object from the adjacency matrix, and I obtained the connectivity for each node with the "degree" function:
graphobj<-graph.adjacency(adjacencymatrix, mode="undirected")
degreenetwork<-degree(graphobj)
Then I have calculated the degree of each node with an other method:
degreenetwork2<-apply(adjacencymatrix, 1,sum)
and I have noticed that the degree of the nodes is not always preserved. In fact the the two methods give me different value of connectivity for the nodes. For example:
mean(degreenetwork)
[1] 156.068
mean(degreenetwork2)
[1] 78.034
min(degreenetwork)
[1] 17
min(degreenetwork2)
[1] 0
max(degreenetwork)
[1] 521
max(degreenetwork2)
[1] 452
Is there something wrong, or am I not using correctly the igraph package?
Regards
Gianni