<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -116,3 +116,51 @@ void Graph::unweighted(int from) {
 	}
 }
 
+/**
+ * This method finds the weighted shortest-path using Dijkstra's algorithm
+ *
+ * @param int
+ *
+ */
+void Graph::weighted(int from) {
+	priority_queue&lt;Path, vector&lt;Path&gt;, greater&lt;Path&gt; &gt; pq;
+	Path vrec;
+
+	vector_map::iterator i = vmap.find(from);
+	if (i == vmap.end() )
+		throw GraphException(from + &quot; isn't a vertex in this graph&quot;);
+
+	clearAlg();
+	Vertex *first = (*i).second;
+	pq.push(Path(first, 0) ); 
+	start-&gt;dist = 0;
+
+	int totalVs = vmap.size();
+	for (int visitedVs = 0; visitedVs &lt; totalVs; ++vistedVs) {
+		do {
+			if (pq.empty() ) return;
+			vrec = pq.top();
+			pq.pop();
+		} while (vrec.to-&gt;scraatch != 0);
+
+		Vertex *v vrec.dest;
+		v-&gt;scratch = 1;
+
+		int vadjs = v-&gt;adj.size();
+		for(int i = 0; i &lt; vadjs; ++i) {
+			Edge e = v-&gt;adj[ i ];
+			Vertex *w = e.dest;
+			double costvw = e.cost;
+			if (costvw &lt; 0) 
+				throw GraphException(&quot;Edges can't have negative cost&quot;);
+
+			if (w-&gt;dist &gt; v-&gt;dist+costvw) {
+				w-&gt;dist = v-&gt;dist + costvw;
+				w-&gt;prev = v;
+				pq.push(Path(w, w-&gt;dist) );
+			}
+		}
+	}
+}
+
+</diff>
      <filename>graf.cpp</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>292d41c82992ad9d9654954abbbf00dc91f1e5dd</id>
    </parent>
  </parents>
  <author>
    <name>Pawel Ptaszynski</name>
    <email>pptaszynski@gmail.com</email>
  </author>
  <url>http://github.com/pptaszynski/aisdi-graf/commit/7fac74fbf49cdde2b2a5082da85a977f5457aa24</url>
  <id>7fac74fbf49cdde2b2a5082da85a977f5457aa24</id>
  <committed-date>2008-06-11T17:26:36-07:00</committed-date>
  <authored-date>2008-06-11T17:26:36-07:00</authored-date>
  <message>Added implementation for searching weighted shortest-path algorithm. Implementation represnets Dijkstra's algorithm</message>
  <tree>4e0f65fd8cb43db7c633b7dec778ab7cfe81a283</tree>
  <committer>
    <name>Pawel Ptaszynski</name>
    <email>pptaszynski@gmail.com</email>
  </committer>
</commit>
