如果您从 R 中使用 igraph,请使用此选项
path {igraph} | R 文档 |
此函数可用于添加或删除形成路径的边。
path(...)
... |
请参见下面的详细信息。 |
通过 +
添加边时,所有未命名的参数都将被连接,最终向量的每个元素都被解释为图中的一个顶点。对于长度为 n+1
的向量,将添加 n
条边,从顶点 1 到顶点 2,从顶点 2 到顶点 3,等等。命名的参数将用作新边的边属性。
删除边时,所有属性都将被连接,然后传递给 delete_edges
。
一个特殊的对象,可以与 igraph 图以及加号和减号运算符一起使用。
用于操作图结构的其他函数:+.igraph()
, add_edges()
, add_vertices()
, delete_edges()
, delete_vertices()
, edge()
, igraph-minus
, 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)[[]]
g4 <- g3 + path(c("f", "c", "j", "d"), width=1:3, color="green")
E(g4)[[]]