Question: In this project, we will be computing a shortest path between two vertices of an unweighted graph using Breadth First Search the Queue as well.

 In this project, we will be computing a shortest path between
two vertices of an unweighted graph using Breadth First Search the Queue

In this project, we will be computing a shortest path between two vertices of an unweighted graph using Breadth First Search the Queue as well. 5) SF$ uses a Queue, and we will implement Files provided in the project 1) Queueh. This file contains the prototypes and definitions for the functions for a queue. You need to implement the following functions in the file Queue.c a. Queue newQuee) Malloc a new quue, initialie its values, and return its b. void freeQueuelQueue q). Free all the nemaining nodes in the Queue and then free c. NodeQ .allocateNodeQrVertex v1Given a vertex of the graph, maloc a node to d. void insertQlQueue q, Vertex vi. Add a new node containing w and add it to the end e. int removeQlQueue q. Vertex "w. Assemgts to remove the node at the head of the the Queue itsell store this node and return its addres of the queue. queue. If the queue is empty, it returns FALSE If the queue is not empty, it returns the vertex through 'v (passed by reference) and functionally returns TRUE 2) Graph.h This file contains the prototypes of al of the functions we wil be using for an adjacency matrix implementation of a Graph. You must provide the implementation of the following functions in Graphs a Graph newGraph int m). This function takes as input the number of vertices of the graph, and mallocs a new graph, mallocs an man aray for the adjacency matrix of the graph, initializes each value of the matrix to be O Ino edges yet), and then returns the address of the graph b, void freeGraph Graph d. Free the adjacency matrix and then the graph itself c, void addfdge(Graph Edge e). Given graph and an edge, set the corresponding entry in the adjacency matrix to be 1 d. Edge firstAdjacentlGraph g Vertex . Given a graph and a vertex v, return the first edge of the graph that has v asthe 7h0mlerter". no such edge ents return an edge with both the fromVertex and tovertex set to be-1 Edge nextAdjacentlGraph &Edge e Gven a graph g and an edge e, find edge in g after e that has the same Tromvenex as e. if no such edge exists return an edge with both the fromvertex and ertex set tobe-L e. the next t void shortestPathlGraph t. Vertex start, Vertex destination). Compute a shortesz path in g starting at "gar-and endng "degnation" using Breadth First Search. If a shortest path exists, then print the sequence of vertices along the path that you computed. If no path exists, then print a meage saying that there does not exist a path 3) pelnput.txt. The project will contain the information for a single graph, and then will ask you to compute several shortest paths for different startjdestination pairs for the same graph. The first line contains the number of vertices in the ap, and the second Ine contans tht number of (directed) edges in the graph. The next set of lines contains two integers representing the fromVertex and the toVertex for each edge. For eample, the line 35 implies that we should add an edge from vertex 3 to vertex S in the graph Next is a single integer which represents the number of shortest paths you will need to compute. The remaining ines tells you which shortest paths to compute. For example, "ShortestPath: 08 implies that you should compute a shortest path starting at vertex 0 and ening vertex 8. 4) abk123Project6.c. Rename this file to your abc123. This ile should parse the input from p6input txt. create the graph, and then call the shortethth tion for each of the requested pairs 5) Makefile. Update the makefile to reflect your abc123. Comple using make p6. Execute the program usingpb pinput.tat

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!