Your task for this assignment is to identify a spanning tree in a connected undirected weighted graph using C++. 1. Implement a spanning tree algorithm using C++. A spanning tree is an acyclic spanning subgraph of the of a connected undirected weighted graph. Your program will be interactive. Graph edges with respective weights (i.e., v1 v2 w) are entered at the command line and results are displayed on the console. 2. Each input transaction represents an undirected edge of a connected weighted graph. The edge consists of two unequal uppercase letters representing graph vertices that the edge connects. Each edge has an assigned weight. The edge weight is a positive integer in the range 1 to 99. The three values on each input transaction are separated by a single space. An input transaction containing the string “end-of-file” signals the end of the graph edge input. After the edge information is read, the spanning tree evaluation process begins. Use an adjacency matrix for recording input edges and show all code used to determine the spanning tree. The input data is assumed to be valid. There is no need to perform data validation on the input data. 3. After the edges of the spanning tree are determined, the tree edges are displayed on the console, one edge per output line, following the message: “Spanning tree:”. Each output line representing a tree edge contains edge vertices separated by space. Sample input transactions are as follows: A B 2 A C 4 A D 10 A E 6 B C 3 B D 8 B E 1 C D 55 C E 7 D E 9 end-of-file Sample output expected after processing the above input will be as follows: 2 Spanning tree: A C B C A D D E 4. The program will be run at the command prompt by navigating to the directory containing the executable version of the program after the program is compiled.
Your task for this assignment is to identify a spanning tree in a connected undirected weighted graph using C++.
1. Implement a spanning tree
2. Each input transaction represents an undirected edge of a connected weighted graph. The edge consists of two unequal uppercase letters representing graph vertices that the edge connects. Each edge has an assigned weight. The edge weight is a positive integer in the range 1 to 99.
The three values on each input transaction are separated by a single space. An input transaction containing the string “end-of-file” signals the end of the graph edge input. After the edge information is read, the spanning tree evaluation process begins. Use an adjacency matrix for recording input edges and show all code used to determine the spanning tree. The input data is assumed to be valid. There is no need to perform data validation on the input data.
3. After the edges of the spanning tree are determined, the tree edges are displayed on the console, one edge per output line, following the message: “Spanning tree:”. Each output line representing a tree edge contains edge vertices separated by space.
Sample input transactions are as follows: A B 2 A C 4 A D 10 A E 6 B C 3 B D 8 B E 1 C D 55 C E 7 D E 9 end-of-file Sample output expected after processing the above input will be as follows:
2 Spanning tree: A C B C A D D E 4.
The program will be run at the command prompt by navigating to the directory containing the executable version of the program after the program is compiled.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps