Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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. image text in transcribed

Here is the code from the directed graph file: #include using namespace std; #include "GRAPH.h"

void main() { char vertex[] = {'S', 'R', 'G', 'B', 'O', 'T', 'V'}; int numVertices = sizeof(vertex)/sizeof(char); GRAPH g(vertex, numVertices);

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions

Question

What factors affect the taxability of capital gains and losses?

Answered: 1 week ago

Question

Write formal proposal requests.

Answered: 1 week ago

Question

Write an effective news release.

Answered: 1 week ago

Question

Identify the different types of proposals.

Answered: 1 week ago