Delete vertices from a graph
See also
Other functions for manipulating graph structure:
+.igraph(),
add_edges(),
add_vertices(),
complementer(),
compose(),
connect(),
contract(),
delete_edges(),
difference(),
difference.igraph(),
disjoint_union(),
edge(),
igraph-minus,
intersection(),
intersection.igraph(),
path(),
permute(),
rep.igraph(),
reverse_edges(),
simplify(),
transitive_closure(),
union(),
union.igraph(),
vertex()
Examples
g <- make_ring(10) %>%
set_vertex_attr("name", value = LETTERS[1:10])
g
#> ── <igraph> Ring graph ────────────────────────────────────────────── 508b2dd ──
#> ℹ undirected · named
#> ℹ 10 vertices · 10 edges
#>
#> ── Attributes ──────────────────────────────────────────────────────────────────
#> → graph: name <chr>, mutual <lgl>, circular <lgl>
#> → vertex: name <chr>
#>
#> ── Edges (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)
#> ── <vertex sequence> 10/10 · named · from 508b2dd ──────────────────────────────
#> [1] A B C D E F G H I J
g2 <- delete_vertices(g, c(1, 5)) %>%
delete_vertices("B")
g2
#> ── <igraph> Ring graph ────────────────────────────────────────────── a28ea8d ──
#> ℹ undirected · named
#> ℹ 7 vertices · 5 edges
#>
#> ── Attributes ──────────────────────────────────────────────────────────────────
#> → graph: name <chr>, mutual <lgl>, circular <lgl>
#> → vertex: name <chr>
#>
#> ── Edges (vertex names) ────────────────────────────────────────────────────────
#> [1] C ─ D F ─ G G ─ H H ─ I I ─ J
V(g2)
#> ── <vertex sequence> 7/7 · named · from a28ea8d ────────────────────────────────
#> [1] C D F G H I J
