code: def eulerian_tour_undirected(graph):
      
      P = []
      Q = [0]
      R = []
      succ = [0] * len(graph)
      seen = [set() for _ in graph]
      while Q:
          node = Q.pop()
          P.append(node)
          while succ[node] < len(graph[node]):
              neighbor = graph[node][succ[node]]
              succ[node] += 1
              if neighbor not in seen[node]:
                  seen[neighbor].add(node)
                  R.append(neighbor)
                  node = neighbor
          while R:
              Q.append(R.pop())
      return P
docs: Eulerian tour on an undirected graph
  
         :param graph: directed graph in listlist format, cannot be listdict
         :assumes: graph is eulerian
         :returns: eulerian cycle as a vertex list
         :complexity: `O(|V|+|E|)`