Function to reorder vertices?

, ,

Is there a function that re-orders vertices while preserving vertex and edge attributes? I am primarily interested in the Python interface, but if there is a function, I’d also like to know its name in C and R.

I could not find one, but this seems like a fairly fundamental operation, so perhaps I missed it.

Example to clarify:

Given a directed graph with vertices 0, 1, 2 and one edge 1 -> 2, permute/rename the vertices as

0 -> 2
1 -> 1
2 -> 0

to obtain the graph with the edge 1 -> 0.

It is called igraph_permute_vertices(). I think it can also be (ab)used to calculate induced subgraphs or to duplicate vertices and the edges incident on them.

Actually, we could probably just delegate the implementation of igraph_induced_subgraph() to this function if the user asked to create the new graph from scratch.

Thanks!

In R: https://igraph.org/r/doc/permute.html

In Python: https://igraph.org/python/doc/igraph.GraphBase-class.html#permute_vertices

In hindsight, it would have been obvious to search for “permute” (I even used that word in the question) but somehow I didn’t …