Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Lab 15 Graph In today's lab we will design and implement the Graph ADT. graphtype.h template # i Ende E GRADHTYPE H INCLUDED GraphTypeVertexType: -GraphType()
Lab 15 Graph In today's lab we will design and implement the Graph ADT. graphtype.h template # i Ende E GRADHTYPE H INCLUDED GraphTypeVertexType: -GraphType() #define GRAPHTYPE H INCLUDED #include "stacktype.h" delete tl vertices; #include "quetype.h" delete [1 marks template for (int i=0;i GraphType(int maxv); void GraphType::MakeEmpty -GraphType(); + void MakeEmpty(); numVertices - 0; bool IsEmpty(); 1 bool Is Full(); template class VertexType> void AddVertex (VertexType); bool GraphType:: IsEmpty void AddEdge (VertexType, VertexType, int); return (numVertices -- 0); int Weight Is (VertexType, } VertexType); template void GetToVertices (VertexType, bool GraphType:: Is Full QueType); void clearMarks(); return (numVertices -- maxvertices); void MarkVertex (VertexType); } bool Ismarked (VertexType); template void DepthFirst Search (VertexType, void GraphType::Addvertex (VertexType VertexType); vertex) void BreadthFirst Search (VertexType, VertexType); vertices [numvertices) - vertex; private: for (int index-0; index heaptype.cpp int Index Is (VertexType* vertices, VertexType include "graphtype.h" vertex) #include "stacktype.cpp" #include "quetype.cpp" int index - 0; #include while (! (vertex -- vertices[index])) using namespace std; index=1 const int NULL_EDGE - 03 return index template template GraphType::GraphType() void GraphType::ClearMarks () numVertices - 0; for (int 1-0; i for(int i=0;i:: MarkVertex (VertexType edges 11 - new int (5017 vertex) marks - new bool(50); int Index - Index Is (vertices, vertex); template class VertexType> marks[index] - true GraphType::GraphType(int maxv) 1 template numVertices - 01 bool GraphType::IsMarked (VertexType maxvertices - maxV; vertex) vertices - new VertexType (maxV): edges - new int[maxV); int index - Index Is (vertices, vertex); for (int 1-0;i void GraphType:: AddEdge (VertexType fromVertex, VertexType tovertex, int weight) int row - Index Is (vertices, fromVertex); int col- Index Is (vertices, toVertex); edges [row][coll - weight; template int GraphType::Weight Is (VertexType fromvertex, VertexType tovertex) t int row - Indexis (vertices, fromVertex); int col- Index Is (vertices, taVertex); return edges (row[coll; template void GraphType::GetToVertices (VertexType vertex, QueType& adjVertices) int from Index, toIndex; from Index - Index Is (vertices, vertex); for (toIndex - 0; toIndex template void void GraphType:: Depth First Search (Vertex GraphType:: BreadthFirst Search (Vertex Type startVertex, VertexType endvertex) Type startVertex, VertexType endvertex) 1 StackType stack Que Type queue; QueType vertexQ; Que Type vertexQ; baal found - false; VertexType vertex, item; bool found - false; VertexType vertex, item, ClearMarks(); stack. Push (startVertex)? ClearMarks 0); do queue. Enqueue (startVertex); do vertex - stack.Top(); stack.pop(); queue. De queue (vertex); if (vertex - endVertex) if (vertex - endvertex) 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