It looks like you already know what the graph should look like, so I believe that if you can use the depth search approach. Although the search during the first breath can be used to avoid recursion.
For example, if you have nodes 1-5 and k = 2, you can plot, starting with node 1, and then just randomly select an invisible node. For instance:
1 [Start at 1] 1-2 [expand 2, add edge(1,2) to graph] 1-2-3 [expand 3, add edge(2,3) to graph] 1-2-3-4 [expand 4, add edge(3,4) to graph] 1-2-3-4-5 [expand 5, add edge(4,5) to graph] 1-2-3-4-5-1 [expand 1, add edge(5,1) to graph] (this step may or may not be done)
If the edge is never used twice, then the paths p will lead to the degree of p * 2 as a whole, and the degree of the start and end nodes depends on whether the routes are really tours. To avoid duplication of work, it is probably easier to simply outline the vertices as integers from 1 to N, and then create edges so that each vertex v connects to the vertex with the number (v + j) mod (N + 1), where j and (N + 1) co-prime <N-1. The last bit makes things a bit problematic, as the number of companions from 1 to N can be limited if N is not prime. This means that for certain values, solutions do not exist, at least in the form of a new Hamiltonian path / tour. However, if you ignore the cooperative aspect and just make j integers from 1 to p, go through each vertex and create edges (instead of using the path approach), you can make all vertices of degree k, where k is an even number> = 2. This is achieved in O (N * k), although it can be dropped to O (N ^ 2) if the co-prime method is used.
Thus, the path for k = 4 will look like this if it starts with 1, with j = 2:
1 [Start at 1] 1-3 [expand 3, add edge(1,3) to graph] 1-3-5 [expand 5, add edge(3,5) to graph] 1-3-5-2 [expand 2, add edge(5,2) to graph] 1-3-5-2-4 [expand 4, add edge(2,4) to graph] 1-3-5-2-4-1 [expand 1, add edge(4,1) to graph] (this step may or may not be done)
Since | V | = 5 and k = 4, the resulting edges form a complete graph, as expected. It also works, since 2 and 5 are joint.
Obtaining an odd degree is a little harder. First we get the degree k-1, then the edges are added so that the odd degree is obtained as a whole. It seems pretty easy to approach (with one or two exceptions) all odd-edge edges, but it seems impossible or at least very complicated with an odd number of vertices and requires careful selection of edges with an even number of vertices, the section of which is not easy to put into the algorithm . However, it can be approximated by simply selecting two unused vertices and creating edges between them, so that the vertices are not used twice, and the edges are not used twice.