Question
I need this written in C++ The file DirectedGraph.cpp contains the code for defining the vertices of a directed graph. Use this file to write
I need this written in C++
The file DirectedGraph.cpp contains the code for defining the vertices of a directed graph. Use this file to write a program which calculates the average ASCII value of all the characters in the graph (sum all the ASCII values of the vertices in the graph, and divide them by the number of vertices in the graph). Put the weights between the vertices to be the differences (in absolute value) between the ASCII code of the starting vertex and the average ASCII value. The direction between two vertices should be determined randomly. If a character is repeated, it should not be included in the graph. From the thus obtained directed graph create a minimum spanning tree according to Dijkstras algorithm that starts from the vertex with the highest ASCII value in the graph. Print the tree.
Here is the code from the directed graph file: #include
void main() { char vertex[] = {'S', 'R', 'G', 'B', 'O', 'T', 'V'}; int numVertices = sizeof(vertex)/sizeof(char); GRAPH
g.setEdge('S', 'R', 10, true); g.setEdge('B', 'S', 80, true); g.setEdge('S', 'T', 120, true); g.setEdge('G', 'R', 40, true); g.setEdge('R', 'O', 60, true); g.setEdge('R', 'V', 120, true); g.setEdge('R', 'T', 90, true); g.setEdge('O', 'G', 100, true); g.setEdge('G', 'B', 30, true); g.setEdge('O', 'B', 80, true); g.setEdge('T', 'O', 20, true); g.setEdge('V', 'T', 30, true);
cout
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started