Calculate structural equivalence

d_structural_equivalence(x, weights = NA, digits = 3, suppressWarnings = TRUE)

Arguments

x

graph of class igraph, network, matrix

weights

Either NA (the default), NULL, or a character string giving an edge attribute name. If NULL, the edge attribute 'weight' will be used if it exists in the graph. If NA, no weight will be applied. If a character, the edge attribute with that name will be used (an error is thrown if that attribute does not occur in x.) If the graph has multiple edges, the edge attribute of an arbitrarily chosen edge (for the multiple edges) is included. Note that the function requires the attribute to be either logical or numeric.

This parameter is ignored if x is a matrix. In this case, the weights are assumed to already be inside the adjacency matrix.

digits

number of decimals to use in the result

suppressWarnings

logical, whether or not any warnings should be returned (if issued by cor).

Value

matrix of size n*n, with n equal to the number of vertices in the graph

Details

Calculate structural equivalence based on correlations. The function, of course, disregards the diagonal.

Vertices are also perfectly structurally equivalent with themselves.

If requested, an edge attribute can be taken into account through the weights argument. By default, no weights are used.

The value varies between \[-1, 1\], with -1 denoting maximally possible distance between two vertices and +1 denoting exact structural equivalence.

An implementation for a network graph, is sedist (with method == "correlation"). This yields the same result, but does not allow the use of a weight.

Examples

if (FALSE) { # \dontrun{
data("judge_net", package = "snafun")
d_structural_equivalence(judge_net)

g1 <- create_random_graph(10, "gnm", m = 15, directed = TRUE, graph = "igraph")
g2 <- create_random_graph(10, "gnm", m = 15, directed = FALSE, graph = "igraph")
d_structural_equivalence(g1)
d_structural_equivalence(g2)
d_structural_equivalence(to_network(g1))
d_structural_equivalence(to_matrix(g1))

g3 <- add_edge_attributes(g1, "weight", value = 1:count_edges(g1))
d_structural_equivalence(g3, weights = NA)  # no weight used
d_structural_equivalence(g3, weights = NULL)
d_structural_equivalence(g3, weights = "weight") # same as NULL
} # }