title: Neareast Neuighbor Heuristic for Traveling Salesman Problem in Java
body: <p>I want to write a java program that solves the traveling salesman problem with the nearest neighbor heuristic. The steps of the algorithm would be something like this:</p>
  
  <p>Step  1: Start  with  any  random  vertex,  call it  current  vertex</p>
  
  <p>Step  2: Find  an  edge which  gives  minimum  distance between the  current  vertex  and  an  unvisited  vertex, call  it  V</p>
  
  <p>Step 3:  Now  set  that  current  vertex  to  unvisited  vertex  V  and mark  that vertex  V  as  visited</p>
  
  <p>Step  4:Terminate the  condition,  if  all  the  vertices  are  visited atleast once</p>
  
  <p>Step  5:  Go  to  step 2</p>
  
  <p>I have problems to figure out which data structures would be suitable to solve this problem. How can I identify the node with the smallest distance to the current node (step 2)? Would a priority queue be a good choice? What other data structures could I use?
  How can I make sure, that the second last node in the tour connects to the start node? Should I use a stack? What else could I use?</p>