Extract the edges that run from an actor to himself

extract_loops(x)

extract_loops_vertex(x)

Arguments

x

input graph of class igraph or network

Value

see above

Details

Several functions in this package deal with loops (also sometimes redundantly called "self-loops")"ties that run from a vertex to that same vertex.

This specific function extracts the edge id's for these loops, so they can be identified and, if required, removed.

extract_loops returns the edge ID's of the loops in the graph

extract_loops_vertex returns a table with two columns, the first contains the vertex that has at least one loop in the graph and the second gives the number of loops for that vertex in the graph.

Examples

data(florentine, package = "snafun")
x <- florentine$flobusiness
has_loops(x)             # FALSE
#> [1] FALSE
extract_loops(x)         # NULL
#> NULL
extract_loops_vertex(x)  # NULL
#> NULL
x <- igraph::add_edges(x, c("Barbadori", "Barbadori", "Medici", "Medici"))
has_loops(x)             # FALSE
#> [1] TRUE
extract_loops(x)         # loops detected
#> [1] 16 17
extract_loops_vertex(x)
#>      vertex number_of_loops
#> 1 Barbadori               1
#> 2    Medici               1