R igraph 手册页

如果您从 R 中使用 igraph,请使用此选项

permute {igraph}R 文档

置换图的顶点

描述

通过置换顶点 ID 创建一个新图。

用法

permute(graph, permutation)

参数

输入图,可以是定向图或无向图。

permutation

一个数值向量,给出要应用的置换。第一个元素是顶点 1 的新 ID,依此类推。1 到 vcount(graph) 之间的每个数字必须恰好出现一次。

详细信息

此函数通过根据指定的映射置换其顶点,从输入图创建一个新图。 使用 canonical_permutation 的输出来调用此函数以创建图的规范形式。

permute 保留图的所有图、顶点和边属性。

一个新的图对象。

作者

Gabor Csardi csardi.gabor@gmail.com

参见

canonical_permutation

示例


# 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))

[包 igraph 版本 1.3.5 索引]