Your task for this assignment is to identify a spanning tree in one 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. The program is 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 non-negative integers in the range 0 to 9 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 integers on each input transaction are separated by space. An input transaction containing the string “end-of-file” signalsthe end of the graph edge input. After the edge information is read, the process begins. Use an adjacency matrix for recording input edges and show all code used to determine the spanning tree. The input data can be assumed to be valid, so 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 two integers separated by space. These integers are the two vertices representing the edge. Sample input transactions are as follows: 1 3 81 3 2 62 1 2 73 end-of-file Sample output expected after processing the above input will be as follows: Spanning tree: 1 3 2 3 2 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 one connected undirected
weighted graph using C++.
1. Implement a spanning tree
subgraph of the of a connected undirected weighted graph. The program is 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 non-negative integers in the range 0 to 9 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 integers on each input transaction are
separated by space. An input transaction containing the string “end-of-file” signalsthe end
of the graph edge input. After the edge information is read, the process begins. Use an
adjacency matrix for recording input edges and show all code used to determine the
spanning tree. The input data can be assumed to be valid, so 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 two integers separated by space. These integers are
the two vertices representing the edge.
Sample input transactions are as follows:
1 3 81
3 2 62
1 2 73
end-of-file
Sample output expected after processing the above input will be as follows:
Spanning tree:
1 3
2 3
2
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 with 5 images