public double FindBestPath(Graph2 g) { try { string start = "0"; // Dijkstra's (modified) weights[start] = 1; PriorityQueue2 pq = new PriorityQueue2(n); pq.InsertOrChange(start, 1); while (!pq.IsEmpty()) { string u = pq.DeleteMax(); foreach (Edge2 e in g.GetNeighbors(u)) { if (weights[e.GetEndVertex()] < weights[u] * e.GetFactor()) { weights[e.GetEndVertex()] = (weights[u] * e.GetFactor()); pq.InsertOrChange(e.GetEndVertex(), weights[e.GetEndVertex()]); } } } } catch (Exception e) { } double best = weights[(n - 1).ToString()]; return(best); }