<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Dijkstra's shortest path' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Dijkstra's shortest path' posted on the 'Java' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Sat, 25 May 2013 17:28:41 -0700</pubDate>
    <lastBuildDate>Sat, 25 May 2013 17:28:41 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Dijkstra's shortest path</title>
      <link>http://www.programmersheaven.com/mb/java/368141/368141/dijkstras-shortest-path/</link>
      <description>i'm stuck translating this pseudo code from wikipedia to java...can anybody help me......&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt; 1  function Dijkstra(Graph, source):
 2      for each vertex v in Graph:           // Initializations
 3          dist[v] := infinity               // Unknown distance function from s to v
 4          previous[v] := undefined
 5      dist[source] := 0                     // Distance from s to s
 6      Q := copy(Graph)                      // All nodes in the graph are unoptimized - thus are in Q
 7      while Q is not empty:                 // The main loop
 8          u := extract_min(Q)               // Remove best vertex from priority queue; returns source on first iteration
 9          for each neighbor v of u:         // where v has not yet been considered
10              alt = dist&lt;span style="text-decoration: underline;"&gt; + length(u, v)
11              if alt &amp;lt; dist[v]              // Relax (u,v)
12                  dist[v] := alt
13                  previous[v] := u
14      return previous[]
&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
public static void Dijkstra(airportGraph g, Vertex v){
		
		ArrayList&amp;lt;Vertex&amp;gt; vertices = g.vertexList;
		
		for (Vertex u : vertices){
			if (u.getName().equals(v.getName()))
				u.setDistance(0);
			else
				u.setDistance(Integer.MAX_VALUE);
		}
		
		PriorityQueue Q = new PriorityQueue(6);
		
		for (Vertex u : vertices)
			Q.enqueue(u);
		
		Vertex u;
		
		while(!Q.isEmpty()){
			u = Q.dequeue();
			for (Edge e: g.incidentEdges(u)) {
				Vertex z = g.opposite(u,e); /// chekc this

				  if ( u.getDistance() + e.getWeight() &amp;lt; z.getDistance() ){
					  z.setDistance(u.getDistance() + e.getWeight());
				  }
				  
			}
		}
	}
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
my vertex class has these fields&lt;br /&gt;
&lt;br /&gt;
private String name;&lt;br /&gt;
	private boolean visited;&lt;br /&gt;
	private int location;&lt;br /&gt;
	private Integer distance;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java/368141/368141/dijkstras-shortest-path/</guid>
      <pubDate>Wed, 19 Dec 2007 08:32:51 -0700</pubDate>
      <category>Java</category>
    </item>
    <item>
      <title>Re: Dijkstra's shortest path</title>
      <link>http://www.programmersheaven.com/mb/java/368141/368144/re-dijkstras-shortest-path/#368144</link>
      <description>Please formulate your problem.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java/368141/368144/re-dijkstras-shortest-path/#368144</guid>
      <pubDate>Wed, 19 Dec 2007 09:32:41 -0700</pubDate>
      <category>Java</category>
    </item>
    <item>
      <title>Re: Dijkstra's shortest path</title>
      <link>http://www.programmersheaven.com/mb/java/368141/368147/re-dijkstras-shortest-path/#368147</link>
      <description>: Please formulate your problem.&lt;br /&gt;
&lt;br /&gt;
need help understanding how to code&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
1  function Dijkstra(Graph, source):
 2      for each vertex v in Graph:           // Initializations
 3          dist[v] := infinity               // Unknown distance function from s to v
 4          previous[v] := undefined
 5      dist[source] := 0                     // Distance from s to s
 6      Q := copy(Graph)                      // All nodes in the graph are unoptimized - thus are in Q
 7      while Q is not empty:                 // The main loop
 8          u := extract_min(Q)               // Remove best vertex from priority queue; returns source on first iteration
 9          for each neighbor v of u:         // where v has not yet been considered
10              alt = dist + length(u, v)
11              if alt &amp;lt; dist[v]              // Relax (u,v)
12                  dist[v] := alt
13                  previous[v] := u
14      return previous[]
&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java/368141/368147/re-dijkstras-shortest-path/#368147</guid>
      <pubDate>Wed, 19 Dec 2007 09:44:48 -0700</pubDate>
      <category>Java</category>
    </item>
    <item>
      <title>Re: Dijkstra's shortest path</title>
      <link>http://www.programmersheaven.com/mb/java/368141/368150/re-dijkstras-shortest-path/#368150</link>
      <description>: : Please formulate your problem.&lt;br /&gt;
: &lt;br /&gt;
: need help understanding how to code&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
Hmm..., haven't you done that already? (coded, that is)&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java/368141/368150/re-dijkstras-shortest-path/#368150</guid>
      <pubDate>Wed, 19 Dec 2007 10:19:23 -0700</pubDate>
      <category>Java</category>
    </item>
    <item>
      <title>Re: Dijkstra's shortest path</title>
      <link>http://www.programmersheaven.com/mb/java/368141/368151/re-dijkstras-shortest-path/#368151</link>
      <description>: : : Please formulate your problem.&lt;br /&gt;
: : &lt;br /&gt;
: : need help understanding how to code&lt;br /&gt;
: : &lt;br /&gt;
: &lt;br /&gt;
: Hmm..., haven't you done that already? (coded, that is)&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
its not working becasue i think im mising something&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java/368141/368151/re-dijkstras-shortest-path/#368151</guid>
      <pubDate>Wed, 19 Dec 2007 10:22:26 -0700</pubDate>
      <category>Java</category>
    </item>
    <item>
      <title>Re: Dijkstra's shortest path</title>
      <link>http://www.programmersheaven.com/mb/java/368141/368153/re-dijkstras-shortest-path/#368153</link>
      <description>: : : : Please formulate your problem.&lt;br /&gt;
: : : &lt;br /&gt;
: : : need help understanding how to code&lt;br /&gt;
: : : &lt;br /&gt;
: : &lt;br /&gt;
: : Hmm..., haven't you done that already? (coded, that is)&lt;br /&gt;
: : &lt;br /&gt;
: &lt;br /&gt;
: its not working becasue i think im mising something&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
If I'm not missing something, you're missing the previous array.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java/368141/368153/re-dijkstras-shortest-path/#368153</guid>
      <pubDate>Wed, 19 Dec 2007 11:48:27 -0700</pubDate>
      <category>Java</category>
    </item>
  </channel>
</rss>