
Concept explainers
C PROGRAMMING
Implement dijkstras alorithm
Check that the Graph graph, and starting node, id, are valid
• Create the set S containing all the networks (vertices) except the source node (you might want
to use an array for this.
• Create an array to represent the table D and initialise it with the weights of the edges from the
source node, or infinity if no edge exists. You should use the constant DBL_MAX to represent
infinity.
• Create an array to represent the table R and initialise it with the next hops if an edge exists
from the source, or 0 otherwise.
• Then repeatedly follow the remaining rules of Dijkstra’s
R until S is empty.
• Each of the values required to complete the above can be found by calling the various
functions (get_vertices(), get_edge(), edge_destination(), edge_weight(), etc.)
in the supplied graph library.
• Once Dijkstra’s algorithm has run, you will need to create the routing table to be returned by
allocating enough memory for the required number of Path structures and filling each entry of
the array.
• Finally, you should free() any unused memory you have allocated, set *pnEntries to the
correct value, and return the pointer to the routing table you’ve just filled in (obviously, you
shouldn’t free that!)
using the below as a starting point:
/*
* dijkstra.c
* ProgrammingPortfolio
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include "graph.h"
#include "dijkstra.h"
/* find shortest paths between source node id and all other nodes in graph. */
/* upon success, returns an array containing a table of shortest paths. */
/* return NULL if *graph is uninitialised or an error occurs. */
/* each entry of the table array should be a Path */
/* structure containing the path information for the shortest path between */
/* the source node and every node in the graph. If no path exists to a */
/* particular desination node, then next should be set to -1 and weight */
/* to DBL_MAX in the Path structure for this node */
Path *dijkstra(Graph *graph, int id, int *pnEntries)
{
Path *table = NULL;
/* Insert your implementation of Dijkstra's algorithm here */
return table;
}

Step by stepSolved in 3 steps with 1 images

- In this assignment you will develop a client-server application. The client will send the server aninteger number to see whether the number is a prime number or not. The server will test the numberand tell the client the result. You have to write a client code and a server code for the project usingeither UDP or TCP socket programming. can i get the code in C++ language and explain the code in detail with outputs?arrow_forwardQuantifyerarrow_forwardC++ Consider the following function as a property of a LinkedBag that contains a Doubly Linked List. Assume a Node has pointers prev and next, which can be read and changed with the standard get and set methods. Assume that the doubly linked list is: 1 <--> 2 <--> 3 <--> 4 <--> 5 <-->6 If you are uncertain what the above diagram depicts, it is a doubly linked list such that: The head of this doubly linked list is the node that contains the value 1. The tail of this doubly linked list is the node that contains the value 6. The 3rd node in this list contains the value 3. The contents of this list are the values 1 through 6 in sequential order. The following questions are regarding the linked list after after the test_function is run. A. The head of the list after the test_function is run contains the value: B. The tail of the list after the test_function is run contains the value: C. The 3rd node in the list after the test_function is run…arrow_forward
- Computer sciencearrow_forward] ] is_bipartite In the cell below, you are to write a function "is_bipartite (graph)" that takes in a graph as its input, and then determines whether or not the graph is bipartite. In other words, it returns True if it is, and False if it is not. After compiling the above cell, you should be able to compile the following cell and obtain the desired outputs. print (is_bipartite({"A" : ["B", "C"], "B" : ["A"], "C" : ["A"]}), is_bipartite({"A" : ["B", "C"], "B" : ["A", "C"], "C" : ["A", "B"]})) This should return True False Python Pythonarrow_forwardMATLAB. write code for all partsarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





