gcov: Find the Covariance(s) Between Two or More Labeled Graphs

View source: R/gmultiv.R

gcovR Documentation

Find the Covariance(s) Between Two or More Labeled Graphs


gcov finds the covariances between the adjacency matrices of graphs indicated by g1 and g2 in stack dat (or possibly dat2). Missing values are permitted.


gcov(dat, dat2=NULL, g1=NULL, g2=NULL, diag=FALSE, mode="digraph")



one or more input graphs.


optionally, a second graph stack.


the indices of dat reflecting the first set of graphs to be compared; by default, all members of dat are included.


the indices or dat (or dat2, if applicable) reflecting the second set of graphs to be compared; by default, all members of dat are included.


boolean indicating whether or not the diagonal should be treated as valid data. Set this true if and only if the data can contain loops. diag is FALSE by default.


string indicating the type of graph being evaluated. "digraph" indicates that edges should be interpreted as directed; "graph" indicates that edges are undirected. mode is set to "digraph" by default.


The graph covariance between two labeled graphs is defined as

cov(G,H) = sum( (A^G_ij-mu_G)(A^H_ij-mu_H), {i,j} )/Choose(|V|,2)

(with A^G being the adjacency matrix of G). The graph correlation/covariance is at the center of a number of graph comparison methods, including network variants of regression analysis, PCA, CCA, and the like.

Note that gcov computes only the covariance between uniquely labeled graphs. For the more general case, gscov is recommended.


A graph covariance matrix


The gcov routine is really just a front-end to the standard cov method; the primary value-added is the transparent vectorization of the input graphs (with intelligent handling of simple versus directed graphs, diagonals, etc.). Classical null hypothesis testing procedures are not recommended for use with graph covariance; for nonparametric null hypothesis testing regarding graph covariance, see cugtest and qaptest.


Carter T. Butts buttsc@uci.edu


Butts, C.T., and Carley, K.M. (2001). “Multivariate Methods for Interstructural Analysis.” CASOS Working Paper, Carnegie Mellon University.

See Also

gscov, gcor, gscor


#Generate two random graphs each of low, medium, and high density

#Examine the covariance matrix

sna documentation built on June 1, 2022, 9:06 a.m.

Related to gcov in sna...