vertex_covariate_compare(graph, X, funname)
dgCMatrix
.dgCMatrix
of size $n*n$ with values in
the form of $funname(X[i],X[j])$.
graph
and
applies a function in the form of $funname(X[i],X[j])$
only to $(i,j)$ that have no empty entry. In other words, applies a compares
elements of X
only between vertices that have a link; making
nlinks(graph)
comparisons instead of looping through $n*n$,
which is much faster.funname
can take any of the following values:
"distance"
, "^2"
or "quaddistance"
, ">"
or "greater"
,
"<"< code=""> or
"smaller"
, ">="
or "greaterequal"
,
"<="< code=""> or
"smallerequal"
, "=="
or "equal"
.
# Basic example ------------------------------------------------------------
set.seed(1313)
G <- rgraph_ws(10, 4, .2)
x <- rnorm(10)
vertex_covariate_compare(G, x, "distance")
vertex_covariate_compare(G, x, "^2")
vertex_covariate_compare(G, x, ">=")
vertex_covariate_compare(G, x, "<=")
Run the code above in your browser using DataLab