Question: / / main . cpp #include GraphM.h #include #include using namespace std; int main ( ) { int v = 0 ; int temp

//main.cpp
#include "GraphM.h"
#include
#include
using namespace std;
int main()
{
int v =0;
int temp =0;
fstream input;
input.open("original_matrix.txt");
// Gets number of vertices in the test file
while (input >> temp)
v++;
input.close();
// Sqrt of v = items in a row of the matrix (number of vertices)
GraphM * graph = new GraphM((int)sqrt(v));
int * mark = new int[(int)sqrt(v)];
//MST 1
int start =0;
cout "Begin MST 1 starting at Vertex 0" endl endl;
graph->read();
Prim(graph, mark, start);
graph->write();
graph->Print();
cout "End of MST 1" endl endl;
//MST 2
graph->Init(sqrt(v));
for (int i =0; i sqrt(v); i++)
mark[i]= INFINITE;
start =2;
mark[start]=0;
cout "Begin MST 2 starting at Vertex 2" endl endl;
graph->read();
Prim(graph, mark, start);
graph->write();
graph->Print();
cout "End of MST 2" endl endl;
//MST 3
graph->Init(sqrt(v));
for (int i =0; i sqrt(v); i++)
mark[i]= INFINITE;
start =4;
mark[start]=0;
cout "Begin MST 3 starting at Vertex 4" endl endl;
graph->read();
Prim(graph, mark, start);
graph->write();
graph->Print();
cout "End of MST 3" endl endl;
delete graph;
delete[] mark;
system("pause");
return 0;
}
---------------------------------------------------------------------------
//Graph.h
#ifndef GRAPH_H
#define GRAPH_H
class Graph
{
private:
void operator =(const Graph&){}
Graph(const Graph&){}
public:
Graph(){}// Default constructor
virtual ~Graph(){}// Base destructor
// Initialize a graph of n vertices
virtual void Init(int n)=0;
// Return: the number of vertices and edges
virtual int NumVertices()=0;
virtual int NumEdges()=0;
// Return vs first neighbor
virtual int first(int v)=0;
// Return vs next neighbor
virtual int next(int v, int w)=0;
// Set the weight for an edge
virtual void setEdge(int v1, int v2, int wght)=0;
// Delete an edge
virtual void deleteEdge(int v1, int v2)=0;
// Determine if an edge is in the graph
virtual bool isEdge(int i, int j)=0;
// Return an edges weight
virtual int weight(int v1, int v2)=0;
// Get and Set the mark value for a vertex
virtual int getMark(int v)=0;
virtual void setMark(int v, int val)=0;
// Used in Prim's Algorithm
virtual void AddEdgetoMST(int v1, int v2)=0;
};
#endif /* GRAPH_H */
------------------------------------------------------------------
//GraphM.h
#ifndef GRAPHM_H
#define GRAPHM_H
#include "book.h"
#include "Graph.h"
#include
#include
using namespace std;
class GraphM : public Graph
{
private:
int numVertex, numEdge;
int **matrix;
int *mark;
public:
GraphM(int numVert)
{ Init(numVert); }
~GraphM()
{
delete [] mark;
for (int i=0; i 0, "Illegal weight value");
if (matrix[v1][v2]==0)
numEdge++;
matrix[v1][v2]= wt;
}
void deleteEdge(int v1, int v2)
{
if (matrix[v1][v2]!=0)
numEdge--;
matrix[v1][v2]=0;
}
bool isEdge(int i, int j)
{ return matrix[i][j]!=0; }
int weight(int v1, int v2)
{ return matrix[v1][v2]; }
int getMark(int v)
{ return mark[v]; }
void setMark(int v, int val)
{ mark[v]= val; }
void read(){
I am going to keep asking this question untill it is solve completely. Everytime it is not completely solved I will downvote. Do not think about answering unless you are going to give complete answer. The last couple people got downvoted because they didnt give me any useful code they gave instructions that are completely useless. READ THE INSTRUCTION I HAVE PROVIDED IN THE SCREENSHOT ATTATCHED. I PAY MONEY TO GET ANSWERS not for useless instructions I already get from the textbook.
/ / main . cpp #include "GraphM.h " #include

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!