Question: You have to write the proper code in C or C++ Language. It will be good for me if you write it in C language.

 You have to write the proper code in C or C++

You have to write the proper code in C or C++ Language. It will be good for me if you write it in C language.

I am giving you code Skeleton [ you have to follow this skeleton must ]

1. Adjacency Matrix Skeleton

2. Adjacency List Skeleton

........................Adjacency Matrix Skeleton...............

#include #define MAX_VERTICES 20 class Graph{ int matrix[MAX_VERTICES][MAX_VERTICES]; int num_vertices; bool is_directed; bool visited[MAX_VERTICES]; int parent[MAX_VERTICES]; int distance[MAX_VERTICES]; void AddEdge(int u,int v); void RemoveEdge(int u,int v); void BFS(int source); void DFS(int source); int getDistance(int s,int d); void printParentTree(); }; int main() { Graph g1, g2; g1.is_directed=true; g1.num_vertices=10; g2.is_directed=false; g2.num_vertices=8; return 0; }

########################################################################

........................Adjacency List Skeleton...............

#include #define MAX_VERTICES 20 class Graph{ vector adjacencyList[MAX_VERTICES]; int num_vertices; bool is_directed; bool visited[MAX_VERTICES]; int parent[MAX_VERTICES]; int distance[MAX_VERTICES]; void AddEdge(int u,int v); void RemoveEdge(int u,int v); void BFS(int source); void DFS(int source); int getDistance(int s,int d); void printParentTree(); }; int main() { Graph g1, g2; g1.is_directed=true; g1.num_vertices=10; g2.is_directed=false; g2.num_vertices=8; return 0; } 

Now complete the code properly. You don't need to explain everything just comment out the parts. And please answer properly else skip this. I am fed up with wrong answers.

#ok return the smallest distance

#ParentTree() may run infinitely (okay) #if need add constructor

You need to create Graph Data structure with Adjacency Matrix and Adjacency List void AddEdge(int u, int v); void RemoveEdge(int u, int v); void BFS(int source); void DFS(int source); int getDistance(int s, int d); Implement these function inside two files

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 Databases Questions!