After some examination, igraph's calculations for density of a graph with self-loops is counter to what I expected. Here is what I expected (in R) assuming an undirected, unweighted graph G with adjacency matrix 'A' (of R class 'matrix'):
( sum(A[upper.tri(A)]) + sum(diag(A)) )/((n*(n-1)/2) + n)
However, igraph's graph.density(G,loops=T) calculates:
( sum(A[upper.tri(A)]) + sum(diag(A)) )/((n*(n-1)/2) + n/2)
Would someone point me to some literature that states the self-loop part of the divisor in an undirected graph should
be halved? Or is igraph's calculation incorrect?
Thanks.
Jay