code: def testCanonicalPermutation(self):
      # Simple case: two ring graphs
      g1 = Graph(4, [(0, 1), (1, 2), (2, 3), (3, 0)])
      g2 = Graph(4, [(0, 1), (1, 3), (3, 2), (2, 0)])
  
      cp = g1.canonical_permutation()
      g3 = g1.permute_vertices(cp)
  
      cp = g2.canonical_permutation()
      g4 = g2.permute_vertices(cp)
  
      self.assertTrue(g3.vcount() == g4.vcount())
      self.assertTrue(
          sorted(g3.get_edgelist()) == sorted(g4.get_edgelist())
      )
  
      # Simple case with coloring
      cp = g1.canonical_permutation(color=[0, 0, 1, 1])
      g3 = g1.permute_vertices(cp)
  
      cp = g2.canonical_permutation(color=[0, 0, 1, 1])
      g4 = g2.permute_vertices(cp)
  
      self.assertTrue(g3.vcount() == g4.vcount())
      self.assertTrue(
          sorted(g3.get_edgelist()) == sorted(g4.get_edgelist())
      )
  
      # More complicated one: small GRG, random permutation
      g = Graph.GRG(10, 0.5)
      perm = list(range(10))
      shuffle(perm)
      g2 = g.permute_vertices(perm)
      g3 = g.permute_vertices(g.canonical_permutation())
      g4 = g2.permute_vertices(g2.canonical_permutation())
  
      self.assertTrue(g3.vcount() == g4.vcount())
      self.assertTrue(
          sorted(g3.get_edgelist()) == sorted(g4.get_edgelist())
      )
  
imports: import unittest
  from random import shuffle
  from igraph import Graph
label_desc: Use image node_id 1 for calling the PermutationTests obj's underlying member method code with example usage: obj.testCanonicalPermutation() without return types