跳到内容

从图中删除边

用法

delete_edges(graph, edges)

参数

graph

输入图。

edges

要删除的边,指定为边序列。 通常,这是一个包含边 ID 的数字向量,或一个包含源和目标顶点 ID 或名称的字符向量,以 | 分隔

删除边后的图。

参见

示例

g <- make_ring(10) %>%
  delete_edges(seq(1, 9, by = 2))
g
#> IGRAPH 08ed4e7 U--- 10 5 -- Ring graph
#> + attr: name (g/c), mutual (g/l), circular (g/l)
#> + edges from 08ed4e7:
#> [1] 2-- 3 4-- 5 6-- 7 8-- 9 1--10

g <- make_ring(10) %>%
  delete_edges("10|1")
g
#> IGRAPH 6bd2ecd U--- 10 9 -- Ring graph
#> + attr: name (g/c), mutual (g/l), circular (g/l)
#> + edges from 6bd2ecd:
#> [1] 1-- 2 2-- 3 3-- 4 4-- 5 5-- 6 6-- 7 7-- 8 8-- 9 9--10

g <- make_ring(5)
g <- delete_edges(g, get_edge_ids(g, c(1, 5, 4, 5)))
g
#> IGRAPH b01e254 U--- 5 3 -- Ring graph
#> + attr: name (g/c), mutual (g/l), circular (g/l)
#> + edges from b01e254:
#> [1] 1--2 2--3 3--4