Skip to main content
3 of 8
saved 2 bytes
Arnauld
  • 197.8k
  • 20
  • 179
  • 650

#JavaScript (ES6),  160  158 bytes

This is quite inefficient and will time-out on TIO for \$n\ge5\$.

n=>(g=(o,v,p)=>[...Array(N=2*n),N-1,1,n].reduce((s,x,i)=>v>>(x=i<N?i:(p+x)%N)&1?s:s+g((i>=N)/p?[...o,p<x?p*n*n+x:x*n*n+p]:o,v|1<<x,x),g[o.sort()]^(g[o]=1)))``

Try it online!

###Commented

n => (                        // n = input
  g = (                       // g = recursive function taking:
    o,                        //   o[] = array holding visited edges
    v,                        //   v   = bitmask holding visited vertices
    p                         //   p   = previous vertex
  ) =>                        // we iterate over an array of N + 3 entries, where N = 2n:
    [ ...Array(N = 2 * n),    //   - 0...N-1: each vertex of the N-gon
      N - 1,                  //   - N      : previous vertex
      1,                      //   - N+1    : next vertex
      n                       //   - N+2    : opposite vertex
    ].reduce((s, x, i) =>     // reduce() loop with s = accumulator, x = vertex, i = index:
      v >> (x = i < N         //   test the x-th bit of the bitmask v, with:
                ? i           //     x = i if i < N
                : (p + x) % N //     or (p + x) mod N otherwise
      ) & 1 ?                 //   if this vertex was already visited:
        s                     //     leave s unchanged
      :                       //   else:
        s +                   //     add to s
        g(                    //     the result of a recursive call:
          (i >= N) / p ?      //       if p and x are connected (i >= N and p is defined):
            [ ...o,           //         append to o[]:
              p < x           //           the edge formed by p and x
              ? p * n * n + x //           and uniquely identified by
              : x * n * n + p //           min(p, x) * n² + max(p, x)
            ]                 //
          :                   //       else:
            o,                //         leave o[] unchanged
          v | 1 << x,         //       mark the vertex x as visited
          x                   //       previous vertex = x
        ),                    //     end of recursive call
      g[o.sort()] ^           //   sort the edges and yield 1 if this list of edges has not
      (g[o] = 1)              //   already been encountered; either way, save it in g
    )                         // end of reduce()
)``                           // initial call to g with o = ['']
Arnauld
  • 197.8k
  • 20
  • 179
  • 650