permute_graph function

Permute the values of a matrix