Question: Input First line contains a number n, which represent n information of path. After first line, there are n lines, each line contains 3 number,

Input
First line contains a number n, which represent n information of path.
After first line, there are n lines, each line contains 3 number, which represent node i, node j, probability, respectively.
- node i, node j: a path connect node i to node j, note that every paths are undirected.
- probability: probability of the path,0
All the nodes are named by "number".
There's NO SPACE at the end of input and output sequence.
Output
Please print the total probability of the path, and round off the probability to 4th decimal place.
Note that if the total probability is below 0.05, print 0.
sample input 1:
3 1 2 0.7 2 3 0.8 1 3 0.9
sample output 1:
0.72
sample input 2:
1 1 2 0.04
sample output 2:
0
Path with maximum Probability Given n paths with probability, please perform the following operations: (1) implement Kruskal's Algorithm to find the MST with maximum probability to go from node A to node B, and print the probability. (2) if there is an available path but the total probability is below 0.05, print 0. For example: 0.7 1 2 0.9 0.8 3 the probability of the path: 0.9*0.8=0.72
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
