5
public Pair(int to, double prob) {12
public double maxProbability(int n, int[][] edges, double[] succProb, int start, int end) {13
List<List<Pair>> adj = new ArrayList<>();14
for (int i = 0; i < n; i++) {15
adj.add(new ArrayList<Pair>());17
for (int i = 0; i < edges.length; i++) {18
adj.get(edges[i][0]).add(new Pair(edges[i][1], succProb[i]));19
adj.get(edges[i][1]).add(new Pair(edges[i][0], succProb[i]));21
// node,to node,probability22
double probs[] = new double[n];23
Arrays.fill(probs, 0.0);25
PriorityQueue<Pair> pq = new PriorityQueue<>((p1, p2) -> Double.compare(p2.prob, p1.prob));26
pq.offer(new Pair(start, 1.0));27
while (!pq.isEmpty()) {28
Pair curr = pq.poll();29
for (Pair x : adj.get(curr.to)) {30
if (((curr.prob) * (x.prob)) > probs[x.to]) {31
probs[x.to] = ((curr.prob) * (x.prob));32
pq.offer(new Pair(x.to, probs[x.to]));