write a program that recursively searches a network for a path between two nodes.

 

You are to write a program that recursively searches a network for a path between two nodes.  The user will enter the starting node and ending node and the program will display a) if a path between the nodes exists, b) each node on the found path (inclusive), and c) how many nodes make up the path (inclusive).  The program must terminate when the user chooses -1 for either the start or ending node.

The program must also display the network before each user selection.

 

Input:  The network structure is stored in a data file called “network.txt”.  You may assume that there are 11 nodes in the network (use array size 11).

The network is stored in the file on 11 lines.  Each line in the input file represents a single node on the network.  A line of input lists the other nodes that connect to the current machine. Every line terminates with a -1.

For example:

This network: Would be stored like so:
3 -1

2 3 -1

1 -1

0 1 4 6 -1

3 5 7 -1

4 7 8 -1

3 7 -1

4 5 6 8 -1

5 7 -1

10 -1

9 -1

 

 

Your path does not need to be the shortest path, just a valid path.  Your program must work for any network of 11 nodes that are connected in any combination.

Note that a node searching for itself must find itself in one step.

When displaying the found path, you may show it either start to end or in end to start.

You may assume that data in the file is correctly formatted, but you must error trap for users either entering nodes that don’t exist, or not entering your program termination value.

Include welcoming/goodbye messages.

 

Output: There is an executable version of this program on Moodle

 

What to turn in: Your source file. Either “Program4.cpp” or “NetRecursion.cpp”

Order from us and get better grades. We are the service you have been looking for.