centrality {qgraph}R Documentation

Centrality statistics of graphs

Description

This function can be used on the output of qgraph to compute the node centrality statistics for weighted graphs proposed by Opsahl, Agneessens and Skvoretz (2010).

Usage

centrality(graph, alpha = 1, posfun = abs)

Arguments

graph

A "qgraph" object obtained from qgraph

alpha

The tuning parameter. Defaults to 1.

posfun

A function that converts positive and negative values to only positive. Defaults to the absolute value.

Details

This function computes and returns the in and out degrees, closeness and betweenness as well as the shortest path lengths and shortest paths between all pairs of nodes in the graph. For more information on these statistics, see Opsahl, Agneessens and Skvoretz (2010).

These statistics are only defined for positive edge weights, and thus negative edge weights need to be transformed into positive edge weights. By default, this is done by taking the absolute value.

The algorithm used for computing the shortest paths is the well known "Dijkstra’s algorithm" (Dijkstra, 1959). The algorithm has been implemented in R, which can make this function take several minutes to run for large graphs (over 100 nodes). A future version of qgraph will include a compiled version to greatly speed up this function.

Value

A list containing:

OutDegree

A vector containing the outward degree of each node.

InDegree

A vector containing the inward degree of each node.

Closeness

A vector containing the closeness of each node.

Betweenness

A vector containing the betweenness of each node

ShortestPathLengths

A matrix containing the shortest path lengths of each pairs of nodes. These path lenghts are based on the inverse of the absolute edge weights raised to the power alpha.

ShortestPaths

A matrix of lists containing all shortest path lengths between all pairs of nodes. Use double square brackets to index. E.g., if the list is called 'res', res$ShortestPaths[[i,j]] gives a list containing all shortest paths between node i and j.

Author(s)

Sacha Epskamp (qgraph@sachaepskamp.com)

References

Opsahl, T., Agneessens, F., Skvoretz, J. (2010). Node centrality in weighted networks: generalizing degree and shortest paths. Soc Netw. 32:245–251.

Dijkstra, E.W. (1959). A note on two problems in connexion with graphs. Numerische Mathematik 1, 269–271.

See Also

qgraph

Examples


set.seed(1)
adj <- matrix(sample(0:1,10^2,TRUE,prob=c(0.8,0.2)),nrow=10,ncol=10)
Q <- qgraph(adj)

plot of chunk unnamed-chunk-1


centrality(Q)
## $OutDegree
##  [1] 3 2 0 2 1 2 2 1 2 2
## 
## $InDegree
##  [1] 3 1 2 1 1 1 2 4 0 2
## 
## $Closeness
##  [1] 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.04 0.00
## 
## $Betweenness
##  [1] 28 13  0 12 12 12 10 13  0 14
## 
## $ShortestPathLengths
##       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
##  [1,]    0    3    1    2    1    4    1    2  Inf     3
##  [2,]    2    0    3    4    3    1    3    1  Inf     5
##  [3,]  Inf  Inf    0  Inf  Inf  Inf  Inf  Inf  Inf   Inf
##  [4,]    1    3    2    0    2    4    2    2  Inf     1
##  [5,]    2    4    3    1    0    5    3    3  Inf     2
##  [6,]    1    2    2    3    2    0    2    1  Inf     4
##  [7,]    1    2    2    3    2    3    0    1  Inf     4
##  [8,]    3    1    4    5    4    2    4    0  Inf     6
##  [9,]    3    3    1    5    4    4    2    2    0     1
## [10,]    2    2    3    4    3    3    1    1  Inf     0
## 
## $ShortestPaths
##       [,1]   [,2]   [,3]   [,4]   [,5]   [,6]   [,7]   [,8]   [,9]  
##  [1,] List,0 List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,0
##  [2,] List,1 List,0 List,1 List,1 List,1 List,1 List,1 List,1 List,0
##  [3,] List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0
##  [4,] List,1 List,1 List,1 List,0 List,1 List,1 List,2 List,1 List,0
##  [5,] List,1 List,1 List,1 List,1 List,0 List,1 List,2 List,1 List,0
##  [6,] List,1 List,1 List,1 List,1 List,1 List,0 List,1 List,1 List,0
##  [7,] List,1 List,1 List,1 List,1 List,1 List,1 List,0 List,1 List,0
##  [8,] List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,0 List,0
##  [9,] List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,0
## [10,] List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,0
##       [,10] 
##  [1,] List,1
##  [2,] List,1
##  [3,] List,0
##  [4,] List,1
##  [5,] List,1
##  [6,] List,1
##  [7,] List,1
##  [8,] List,1
##  [9,] List,1
## [10,] List,0


[Package qgraph version 1.2 Index]