code: def get_closed_cycles(self):
          closed_cycles = []
          todo = set(self.forward.keys())
          if todo != set(self.forward.values()):
              raise GraphError("The subject and pattern graph must have the same "
                               "numbering.")
          current_vertex = None
          while len(todo) > 0:
              if current_vertex == None:
                  current_vertex = todo.pop()
                  current_cycle = []
              else:
                  todo.discard(current_vertex)
              current_cycle.append(current_vertex)
              next_vertex = self.get_destination(current_vertex)
              if next_vertex == current_cycle[0]:
                  if len(current_cycle) > 1:
                      pivot = np.argmin(current_cycle)
                      current_cycle = current_cycle[pivot:] + \
                                      current_cycle[:pivot]
                      closed_cycles.append(current_cycle)
                  current_vertex = None
              else:
                  current_vertex = next_vertex
          closed_cycles.sort()
          closed_cycles = tuple(tuple(cycle) for cycle in closed_cycles)
          return closed_cycles