# permute: Permute the vertices of a graph In igraph: Network Analysis and Visualization

 permute R Documentation

## Permute the vertices of a graph

### Description

Create a new graph, by permuting vertex ids.

### Usage

``````permute(graph, permutation)
``````

### Arguments

 `graph` The input graph, it can directed or undirected. `permutation` A numeric vector giving the permutation to apply. The first element is the new id of vertex 1, etc. Every number between one and `vcount(graph)` must appear exactly once.

### Details

This function creates a new graph from the input graph by permuting its vertices according to the specified mapping. Call this function with the output of `canonical_permutation()` to create the canonical form of a graph.

`permute()` keeps all graph, vertex and edge attributes of the graph.

### Value

A new graph object.

### Author(s)

Gabor Csardi csardi.gabor@gmail.com

`canonical_permutation()`

Other functions for manipulating graph structure: `+.igraph()`, `add_edges()`, `add_vertices()`, `complementer()`, `compose()`, `connect()`, `contract()`, `delete_edges()`, `delete_vertices()`, `difference.igraph()`, `difference()`, `disjoint_union()`, `edge()`, `igraph-minus`, `intersection.igraph()`, `intersection()`, `path()`, `rep.igraph()`, `reverse_edges()`, `simplify()`, `union.igraph()`, `union()`, `vertex()`

### Examples

``````
# 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 documentation built on Aug. 10, 2023, 9:08 a.m.