code: def test_cycle(self):
      # Self cycle
      self._assert_cycle({1: {1}}, [1, 1])
      # Simple cycle
      self._assert_cycle({1: {2}, 2: {1}}, [1, 2, 1])
      # Indirect cycle
      self._assert_cycle({1: {2}, 2: {3}, 3: {1}}, [1, 3, 2, 1])
      # not all elements involved in a cycle
      self._assert_cycle(
          {1: {2}, 2: {3}, 3: {1}, 5: {4}, 4: {6}}, [1, 3, 2, 1]
      )
      # Multiple cycles
      self._assert_cycle(
          {1: {2}, 2: {1}, 3: {4}, 4: {5}, 6: {7}, 7: {6}}, [1, 2, 1]
      )
      # Cycle in the middle of the graph
      self._assert_cycle({1: {2}, 2: {3}, 3: {2, 4}, 4: {5}}, [3, 2])
  
imports: import graphlib
  import os
  import unittest
  from test.support.script_helper import assert_python_ok
label_desc: Use image node_id 9 for calling the TestTopologicalSort obj's underlying member method code with example usage: obj.test_cycle() without return types