title: Netlogo Dijkstra algorithm
body: <pre><code>to-report find-path [ init final ]
    ask init [set dist_d 0]
    let current init
    let p_dij []
    set p_dij insert-item 0 p_dij current 
    show &quot;dij&quot;
    while [not (current = final)] 
    [
      ask [neighbors with [pcolor = yellow and not (dist_d = -1)]] of current [set dist_d min (list dist_d (1 + [dist_d] of current))]
      ask current [set dist_d -1]
      let min_d min [dist_d] of neighbors
      set current one-of neighbors with [dist_d = min_d and pcolor = yellow]
      set p_dij insert-item (length p_dij - 1) p_dij current 
    ]
    ask patches with [pcolor = yellow] [set plabel dist_d set plabel-color red]
    report p_dij
  end
  </code></pre>
  <p>I'm trying to find the shortest path using Dijkstra's algorithm. There is a problem with the neighbors, every time the program tries to find the next current node, it comes back to init.</p>