如果您从 R 中使用 igraph,请使用此选项
permute {igraph} | R 文档 |
通过置换顶点 ID 创建一个新图。
permute(graph, permutation)
图 |
输入图,可以是定向图或无向图。 |
permutation |
一个数值向量,给出要应用的置换。第一个元素是顶点 1 的新 ID,依此类推。1 到 |
此函数通过根据指定的映射置换其顶点,从输入图创建一个新图。 使用 canonical_permutation
的输出来调用此函数以创建图的规范形式。
permute
保留图的所有图、顶点和边属性。
一个新的图对象。
Gabor Csardi csardi.gabor@gmail.com
# Random permutation of a random graph
g <- sample_gnm(20, 50)
g2 <- permute(g, sample(vcount(g)))
graph.isomorphic(g, g2)
# Permutation keeps all attributes
g$name <- "Random graph, Gnm, 20, 50"
V(g)$name <- letters[1:vcount(g)]
E(g)$weight <- sample(1:5, ecount(g), replace=TRUE)
g2 <- permute(g, sample(vcount(g)))
graph.isomorphic(g, g2)
g2$name
V(g2)$name
E(g2)$weight
all(sort(E(g2)$weight) == sort(E(g)$weight))