Question: Rearrange the rows and columns of a square matrix according to a specific order.

I obtain the adjacency matrix from a graph. We know that it is indexed according to the order of vertices in the Vertices. But what if I want to rearrange it in a different order? Here is a specific example.

with(GraphTheory):
g:=Graph({{2,3},{1,2}});
Vertices(g); #[1,2,3]
AdjacencyMatrix(g);

I would like to display this matrix in the order of [3, 1, 2].

Please Wait...