Question: Implement in C++ There are n smtp servers connected by network cables. Each of the m cables connects two computers and has a certain latency

Implement in C++

There are n smtp servers connected by network cables. Each of the m cables connects two computers and has a certain latency measured in milliseconds required to send an email message. What is the shortest time required to send a message from server to server along a sequence of cables.

Input The first line of input gives the number of cases, N. N test cases follow. Each one starts with a line containing n (number of servers), m (number of route), S (source) and T(destination). S != T. The next m lines (routes) will each contain 3 integers: 2 different servers (in the range [0, n-1]) that are connected by a bidirectional cable and the latency (w)

Output For each test case, output the line Case #x:, followed by the number of milliseconds required to send a message from S to T. Print unreachable, if there is no route from S to T

Sample Input 3 2 1 0 1 0 1 100 3 3 2 0 0 1 100 0 2 200 1 2 50 2 0 0 1

Sample Output Case #1: 100 Case #2: 150 Case #3: unreachable

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!