A loop edge is an edge from a vertex to itself. An edge is a multiple edge if it has exactly the same head and tail vertices as another edge. A graph without multiple and loop edges is called a simple graph.

## Arguments

- graph
The input graph.

- eids
The edges to which the query is restricted. By default this is all edges in the graph.

## Value

`any_loop()`

and `any_multiple()`

return a logical scalar.
`which_loop()`

and `which_multiple()`

return a logical vector.
`count_multiple()`

returns a numeric vector.

## Details

`any_loop()`

decides whether the graph has any loop edges.

`which_loop()`

decides whether the edges of the graph are loop edges.

`any_multiple()`

decides whether the graph has any multiple edges.

`which_multiple()`

decides whether the edges of the graph are multiple
edges.

`count_multiple()`

counts the multiplicity of each edge of a graph.

Note that the semantics for `which_multiple()`

and `count_multiple()`

is
different. `which_multiple()`

gives `TRUE`

for all occurrences of a
multiple edge except for one. I.e. if there are three `i-j`

edges in the
graph then `which_multiple()`

returns `TRUE`

for only two of them while
`count_multiple()`

returns ‘3’ for all three.

See the examples for getting rid of multiple edges while keeping their original multiplicity as an edge attribute.

## See also

`simplify()`

to eliminate loop and multiple edges.

Other structural.properties:
`bfs()`

,
`component_distribution()`

,
`connect()`

,
`constraint()`

,
`coreness()`

,
`degree()`

,
`dfs()`

,
`distance_table()`

,
`edge_density()`

,
`feedback_arc_set()`

,
`girth()`

,
`is_acyclic()`

,
`is_dag()`

,
`is_matching()`

,
`k_shortest_paths()`

,
`knn()`

,
`reciprocity()`

,
`subcomponent()`

,
`subgraph()`

,
`topo_sort()`

,
`transitivity()`

,
`unfold_tree()`

,
`which_mutual()`

## Author

Gabor Csardi csardi.gabor@gmail.com

## Examples

```
# Loops
g <- make_graph(c(1, 1, 2, 2, 3, 3, 4, 5))
any_loop(g)
#> [1] TRUE
which_loop(g)
#> [1] TRUE TRUE TRUE FALSE
# Multiple edges
g <- sample_pa(10, m = 3, algorithm = "bag")
any_multiple(g)
#> [1] TRUE
which_multiple(g)
#> [1] FALSE TRUE TRUE FALSE TRUE FALSE FALSE TRUE TRUE FALSE TRUE TRUE
#> [13] FALSE TRUE TRUE FALSE FALSE TRUE FALSE TRUE TRUE FALSE FALSE FALSE
#> [25] FALSE TRUE TRUE
count_multiple(g)
#> [1] 3 3 3 2 2 1 3 3 3 3 3 3 3 3 3 2 1 2 3 3 3 1 1 1 3 3 3
which_multiple(simplify(g))
#> [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [13] FALSE
all(count_multiple(simplify(g)) == 1)
#> [1] TRUE
# Direction of the edge is important
which_multiple(make_graph(c(1, 2, 2, 1)))
#> [1] FALSE FALSE
which_multiple(make_graph(c(1, 2, 2, 1), dir = FALSE))
#> [1] FALSE TRUE
# Remove multiple edges but keep multiplicity
g <- sample_pa(10, m = 3, algorithm = "bag")
E(g)$weight <- count_multiple(g)
g <- simplify(g, edge.attr.comb = list(weight = "min"))
any(which_multiple(g))
#> [1] FALSE
E(g)$weight
#> [1] 3 3 2 1 3 1 1 1 2 1 1 1 1 2 1 2 1
```