Skip to contents

Delete vertices from a graph

Usage

delete_vertices(graph, v)

Arguments

graph

The input graph.

v

The vertices to remove, a vertex sequence.

Value

The graph, with the vertices removed.

Examples

g <- make_ring(10) %>%
  set_vertex_attr("name", value = LETTERS[1:10])
g
#> IGRAPH f3e5328 UN-- 10 10 -- Ring graph
#> + attr: name (g/c), mutual (g/l), circular (g/l), name (v/c)
#> + edges from f3e5328 (vertex names):
#>  [1] A--B B--C C--D D--E E--F F--G G--H H--I I--J A--J
V(g)
#> + 10/10 vertices, named, from f3e5328:
#>  [1] A B C D E F G H I J

g2 <- delete_vertices(g, c(1, 5)) %>%
  delete_vertices("B")
g2
#> IGRAPH 6f04718 UN-- 7 5 -- Ring graph
#> + attr: name (g/c), mutual (g/l), circular (g/l), name (v/c)
#> + edges from 6f04718 (vertex names):
#> [1] C--D F--G G--H H--I I--J
V(g2)
#> + 7/7 vertices, named, from 6f04718:
#> [1] C D F G H I J