Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

DirectedGraph.cpp: #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

image text in transcribed

DirectedGraph.cpp:

#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 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 Dijkstra's algorithm that starts from the vertex with the highest ASCII value in the graph. Print the tree

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

Web Database Development Step By Step

Authors: Jim Buyens

1st Edition

0735609667, 978-0735609662

More Books

Students also viewed these Databases questions

Question

4. Explain the strengths and weaknesses of each approach.

Answered: 1 week ago

Question

3. Identify the methods used within each of the three approaches.

Answered: 1 week ago