Problem F
Network Paths

A Wide Area Network is being set up that will contain 25 nodes. For routing purposes, it is necessary to know the fastest and second fastest paths between your site's node, designated A, and any other node in the network. Each of the other nodes is simply referred to using the letters B through Y. All node designators are uppercase letters.

The file NETWORK.TXT holds time delay information for each direct link (connection) in the network. Information for each link appears on a separate line in the file. The form is node1 node2 delay for example, the link AB 6 indicates that A is directly connected to B and that a packet is delayed 6 ms when sent in either direction (A to B or B to A) along the link.

Write a program that can determine the fastest and second fastest path through the network from A to any specified node. Your program should repeatedly prompt for a destination node, then display the fastest path from A to that node (as a series of node designators) and total time for the path, and finally display the second fastest path and its total time. The program must continue prompting for destination nodes and displaying results until a character other than B through Y (uppercase) is entered in response to the prompt.

Below are two examples based on NETWORK.TXT for destination nodes F and Q. This reports that the fastest path from A to F is from A to B to F, taking 12 ms - the second fastest is from A to C to F, taking 13 ms. The fastest path from A to Q is from A to P to Q, taking 26 ms - the second fastest is from A to D to G to Q, taking 28 ms.

Enter destination node: F
The fastest route from A to F is ABF with a delay of 12
The second fastest route from A to F is ACF with a delay of 13

Enter destination node: Q
The fastest route from A to Q is APQ with a delay of 26
The second fastest route from A to Q is ADGQ with a delay of 28