Who are the isolates in the network?

extract_isolates(x, names = TRUE, loops = FALSE)

Arguments

x

network of class network or igraph

names

logical, should the names of the isolates be returned ( TRUE or their IDs (FALSE)? The default is TRUE.

loops

logical, should self-loops (if there are any) be taken into account? Default is FALSE, which is (almost) always what you want.

Value

vector with the isolates

Details

Identifies the isolates (if any) in the network. This function works for objects of class network or graph, potentially bipartite.

The output is a vector with the numbers of the isolates or their names. The latter is the default, but the numbers are returned if there are no names in the network object.

If there are self-loops in the network (ie. a vertex has a tie to or from himself), vertices who do not have ties with others will not be seen as isolates. Therefore, the user can decide whether these self-ties should be taken into account. If FALSE, the default, any self-loops will be ignored and vertices with no ties with others will be identified as isolates. However, in the (uncommon) case where a tie with oneself should no longer make the vertex an isolate, one can set the loops argument to TRUE.

See also

Examples

mat <- matrix(0, nrow = 4, ncol = 4)
# edges, incl one self-loop
mat[1, 3] <- mat[4,4] <- 1
ig <- igraph::graph_from_adjacency_matrix(mat)
extract_isolates(ig)  # 2 4
#> [1] 2 4
# 4 has a loop to itself, including this removes its isolate-ship
extract_isolates(ig, loops = TRUE)  # 2
#> [1] 2
igraph::V(ig)$name <-  LETTERS[1:4]
extract_isolates(ig)  # B D
#> [1] "B" "D"
extract_isolates(ig, names = FALSE)  # 2 4
#> [1] 2 4

nw <- network::as.network(mat, loops = TRUE)
extract_isolates(nw)  # 2 4
#> [1] 2 4
network::set.vertex.attribute(nw, "vertex.names", LETTERS[1:4])
extract_isolates(nw)  # B D
#> [1] "B" "D"
extract_isolates(nw, names = FALSE)  # 2 4
#> [1] 2 4