Create a new graph, by permuting vertex ids.
The input graph, it can directed or undirected.
A numeric vector giving the permutation to apply. The
first element is the new id of vertex 1, etc. Every number between one and
This function creates a new graph from the input graph by permuting its
vertices according to the specified mapping. Call this function with the
canonical_permutation to create the canonical form
of a graph.
permute keeps all graph, vertex and edge attributes of the graph.
A new graph object.
Gabor Csardi email@example.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.