code: def write_cycle(filename, graph, cycle, directed):
      
      n = len(graph)
      weight = [[float('inf')] * n for _ in range(n)]
      for r in range(1, len(cycle)):
          weight[cycle[r-1]][cycle[r]] = r
          if not directed:
              weight[cycle[r]][cycle[r-1]] = r
      write_graph(filename, graph, arc_label=weight, directed=directed)
docs: Write an eulerian tour in DOT format
  
         :param filename: the file to be written in DOT format
         :param graph: graph in listlist format, cannot be listdict
         :param bool directed: describes the graph
         :param cycle: tour as a vertex list
         :returns: nothing
         :complexity: `O(|V|^2 + |E|)`