There is no native function to calculate connectedness but we have all the tools:
dist <-distances(net, mode ="out") ## Get the distances matrixreachability <-is.finite(dist) ## Where are there finite paths?diag(reachability) <-NA## Ignore the diagsum(reachability, na.rm = T) / (vcount(net) * (vcount(net) -1))
[1] 0.7168498
Compactness
Again, no native function but we can get it relatively quickly in a similar manner:
dist <-distances(net, mode ="out") ## Get the distances matrixdiag(dist) <-NA## Ignore the diagsum(1/ dist, na.rm = T) / (vcount(net) * (vcount(net) -1))
[1] 0.2914342
Reciprocity
We calculate reciprocity with the reciprocity() function.
The default is to calculate arc-reciprocity, but we can switch it to the other (less good) measure by setting mode="ratio"
reciprocity(net)
[1] 0.389414
edge_density(net)
[1] 0.09688645
Transitivity:
There is a transitivity() function, which works well with undirected networks. For directed networks we have to make use of the sna library and the gtrans() function.
transitivity(net) ## Treats as undirected
[1] 0.4361186
mat_net <-as_adjacency_matrix(net, sparse = F) # Convert to adj matsna::gtrans(mat_net) ## Call SNA function
[1] 0.4617656
Centralization
Finally, we have centralization. You can use a lot of different measures of centrality to measure centralization and so there are a suite of functions:
center_degree() - Uses degree centrality
center_eigen() - Uses eigen centrality
center_betw() - Uses betweenness
They also all output an object with multiple things to get the centralization score use $centralization