此函数可用于添加或删除构成路径的边。
详细信息
通过 +
添加边时,所有未命名的参数都会被连接起来,最终向量的每个元素都被解释为图中的一个顶点。 对于长度为 \(n+1\) 的向量,将添加 \(n\) 条边,从顶点 1 到顶点 2,从顶点 2 到顶点 3,等等。 命名的参数将用作新边的边属性。
删除边时,所有属性都会被连接起来,然后传递给 delete_edges()
。
参见
用于操作图结构的其他函数:+.igraph()
, add_edges()
, add_vertices()
, complementer()
, compose()
, connect()
, contract()
, delete_edges()
, delete_vertices()
, difference()
, difference.igraph()
, disjoint_union()
, edge()
, igraph-minus
, intersection()
, intersection.igraph()
, permute()
, rep.igraph()
, reverse_edges()
, simplify()
, union()
, union.igraph()
, vertex()
示例
# Create a (directed) wheel
g <- make_star(11, center = 1) + path(2:11, 2)
plot(g)
g <- make_empty_graph(directed = FALSE, n = 10) %>%
set_vertex_attr("name", value = letters[1:10])
g2 <- g + path("a", "b", "c", "d")
plot(g2)
g3 <- g2 + path("e", "f", "g", weight = 1:2, color = "red")
E(g3)[[]]
#> + 5/5 edges from b77de2a (vertex names):
#> tail head tid hid weight color
#> 1 a b 1 2 NA <NA>
#> 2 b c 2 3 NA <NA>
#> 3 c d 3 4 NA <NA>
#> 4 e f 5 6 1 red
#> 5 f g 6 7 2 red
g4 <- g3 + path(c("f", "c", "j", "d"), width = 1:3, color = "green")
E(g4)[[]]
#> + 8/8 edges from 4f9870b (vertex names):
#> tail head tid hid weight color width
#> 1 a b 1 2 NA <NA> NA
#> 2 b c 2 3 NA <NA> NA
#> 3 c d 3 4 NA <NA> NA
#> 4 e f 5 6 1 red NA
#> 5 f g 6 7 2 red NA
#> 6 c f 3 6 NA green 1
#> 7 c j 3 10 NA green 2
#> 8 d j 4 10 NA green 3