r,traveling-salesman,hamiltonian-cycle

As the comments suggest, your question is related to the Traveling Salesman Problem. It is in fact an example of a Hamiltonian path (a path which visits each node once, but does not end where it started). As you might expect, in R there's already a package for that: TSP....

algorithm,graph,cycle,hamiltonian-cycle

Finding an hamiltonian path is a NP-complete problem. You probably won't find a much better solution than trying every permutation of nodes. And if somehow you find it, you'll be instantly rich and famous :) ...

algorithm,graph-theory,dijkstra,np-complete,hamiltonian-cycle

No, this is not possible. Your simplified problem is still NP-hard. A reduction from travelling salesman: Given a graph (V, E), find the shortest path that visits each v in V exactly once. Take an arbitrary vertex v in V. Split v into two vertices v_source and v_sink. Use your...

java,debugging,traveling-salesman,hamiltonian-cycle

The problem is that when you swap outgoing[i] and outgoing[j], you are creating two subtours -- two smaller cycles. For example, suppose numcities=6 and your starting tour is 0 1 2 3 4 5. Suppose your if statement is true for i=1, j=3. Your code sets outgoing[1] = 4 and...

algorithm,graph,hamiltonian-cycle

Let the given graph be G. Starting from a vertex v in the graph, let us trace an arbitrary walk(path with repeated vertices allowed), P, by repeatedly picking a vertex adjacent to the last vertex added to P, without repeated any edges. Terminate if you cannot add any more vertices...