创建两个或多个图的并集。假设这些图具有不相交的顶点集。
详细信息
disjoint_union()
创建两个或多个不相交图的并集。因此,首先重新标记第二个、第三个等图中的顶点,以使其具有完全不相交的图。然后创建一个简单的并集。此函数也可以通过 %du%
运算符使用。
disjoint_union()
处理图、顶点和边的属性。特别是,它使用 vctrs::vec_c()
函数合并顶点和边的属性。对于缺少某些顶点/边属性的图,新图中相应的值将设置为缺失值(标量属性为 NA
,列表属性为 NULL
)。图属性只是复制到结果中。如果这会导致名称冲突,则会通过添加后缀重命名它们:_1、_2 等。
请注意,如果两个图都有顶点名称(即 name
顶点属性),则串联的顶点名称在结果中可能不是唯一的。如果发生这种情况,将发出警告。
如果某些输入图是有向的,而另一些是无向的,则会生成错误。
参见
其他用于操作图结构的函数:+.igraph()
, add_edges()
, add_vertices()
, complementer()
, compose()
, connect()
, contract()
, delete_edges()
, delete_vertices()
, difference()
, difference.igraph()
, edge()
, igraph-minus
, intersection()
, intersection.igraph()
, path()
, permute()
, rep.igraph()
, reverse_edges()
, simplify()
, union()
, union.igraph()
, vertex()
作者
Gabor Csardi csardi.gabor@gmail.com
示例
## A star and a ring
g1 <- make_star(10, mode = "undirected")
V(g1)$name <- letters[1:10]
g2 <- make_ring(10)
V(g2)$name <- letters[11:20]
print_all(g1 %du% g2)
#> IGRAPH 673cc71 UN-- 20 19 --
#> + attr: name_1 (g/c), name_2 (g/c), mode (g/c), center (g/n), mutual
#> | (g/l), circular (g/l), name (v/c)
#> + edges from 673cc71 (vertex names):
#> [1] a--b a--c a--d a--e a--f a--g a--h a--i a--j k--l l--m m--n n--o o--p p--q
#> [16] q--r r--s s--t k--t