Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

UserIntroductionConsider a data communication network that must route data packets ( email , MP 3 files, or videofiles, for example ) . Such a network

UserIntroductionConsider a data communication network that must route data packets (email, MP3 files, or videofiles, for example). Such a network consists of routers connected by physical cables or links. Arouter can act as a source, a destination, or a forwarder of data packets. We can model a networkas a graph with each router corresponding to a vertex and the link or physical connection betweentwo routers corresponding to a pair of directed edges between the vertices.A network that follows the OSPF (Open Shortest Path First) protocol routes packets usingDijkstras shortest path algorithm. The criteria used to compute the weight corresponding to alink can include the time taken for data transmission, reliability of the link, transmission cost, andavailable bandwidth. Typically each router has a complete representation of the network graphand associated information available to it.For the purposes of this project, each link has associated with it the transmission time takenfor data to get from the vertex at one end to the vertex at the other end. You will compute thebest path using the criterion of minimizing the total time taken for data to reach the destination.The shortest time path minimizes the sum of the transmission times of the links along the path.The network topology can change dynamically based on the state of the links and the routers.For example, a link may go down when the corresponding cable is cut, and a vertex may go downwhen the corresponding router crashes. In addition to these transient changes, changes to a networkoccur when a link is added or removed.ExampleConsider a very simplified example of a network at UNCC, with vertices at Belk Gym, WoodwardHall, College of Education, Duke Hall, Grigg Hall, and College of Health and Human Services.See Figure 1 for an illustration. For this example, the shortest time (or fastest) path from Belk(Gym) to (College of) Education is: BelkDukeEducation with a total transmission time of 0.9milliseconds.Your JobYou have five tasks in this project: building the initial graph, updating the graph to reflect changes,finding the shortest path between any two vertices in the graph based on its current state, printingthe graph, and finding reachable sets of vertices. These are described in turn.Building the GraphYour program should run from the command-line:graph network.txtwhere network.txt is a file that contains the initial state of the graph. (Other names besidesnetwork.txt may be used, so you cannot hard-code this.) The format of the file is quite simple.Each link representing two directed edges is listed on a line, and is specified by the names of itstwo vertices followed by the transmission time. Vertices are simply strings (vertex names with nospaces) and the transmission times are floating point numbers. For the above example, the file willlook like:Belk Grigg 1.2Belk Health 0.5Duke Belk 0.6Belk Woodward 0.25Woodward Grigg 1.1Grigg Duke 1.6Health Woodward 0.7Health Education 0.45Woodward Education 1.3Duke Education 0.3Woodward Duke 0.67For each input link, add two directed edges, one in each direction.Changes to the GraphInput about changes to the graph, requests for shortest paths, and requests to print the graph willcome as input queries to be read from the standard input. Here are queries indicating changes tothe graph.addedge tailvertex headvertex transmit time Add a single directed edge from tailvertexto headvertex. Here headvertex and tailvertex are the names of the vertices and transmit timeis a float specifying the transmission time of the edge. If a vertex does not exist in the graphalready, add it to the graph. If the edge is already in the graph, change its transmissiontime. Important note: This can enable two vertices to be connected by a directed edge inone direction and not the other, or enable the transmission times in the two directions to bedifferent.deleteedge tailvertex headvertex Delete the specified directed edge from the graph. Donot remove the vertices. If the edge does not exist, do nothing. Note: This may cause twovertices to be connected by a directed edge in one direction, but not the other.edgedown tailvertex headvertex Mark the directed edge as down and therefore unavailable for use. The response to an edgedown (or edgeup) query should mark only the specifieddirected edge as down (or up). So its companion directed edge (the edge going in theother direction) should not be affected.edgeup tailvertex headvertex Mark the directed edge as up, and available for use. Itsprevious transmission time should be used.vertexdown vertex Mark the vertex as down. None of its edges can be used. Markinga vertex as down should not cause any of its incoming or outgoing edges to be markedas down. So the graph can have up edges going to and leaving from a down vertex.However a path through such a down vertex cannot be used as a valid path.vertexup vertex Mark the vertex as up again.Finding the Shortest PathThe query for finding the shortest path will look likepath from_vertex to_vertexwhere from_vertex and to_vertex are names of vertices. This should compute the shortest timepath from from_vertex to to_vertex using Dijkstras algorithm and based on the current state ofthe graph.The most difficult task is the implementation of Dijkstras algorithm, and especially the priorityqueue (as a min binary heap).The output must be the vertices along the shortest path, followed by the total transmissiontime. For example, with our example graph and no changes to the state of the graph, the querypath Belk Educationshould yield as outputBelk Duke Education 0.9Print GraphThe simple queryprintmust print the contents of the graph. Vertices must be printed in alphabetical order and theoutward edge for each vertex must be printed in alphabetical order. For the example graph, theoutput should beBelkDuke 0.6Grigg 1.2Health 0.5Woodward 0.25DukeBelk 0.6Education 0.3Grigg 1.6Woodward 0.67EducationDuke 0.3Health 0.45Woodward 1.3GriggBelk 1.2Duke 1.6Woodward 1.1Health...Woodward...When a vertex is down, append the word DOWN after the vertex. When an edge is down, appendthe word DOWN after the edge.Reachable VerticesSince the states of the vertices and edges may change with time, it is useful to know the set ofvertices reachable from each vertex by valid paths. You must develop and implement an algorithmthat identifies for each vertex, the set of all its reachable vertices. You should not use the shortestdistance algorithm implemented above to obtain the set of reachable vertices. Important: Additionally, you must describe your algorithm and justify its running time, using O notation, in thecomments for this algorithm in your submitted code.The queryreachablemust print for each up vertex, all vertices that are reachable from it. So vertices that are downor not reachable by up edges will not be printed. Vertices must be printed in alphabetical order,and the set of vertices reachable from each vertex must be printed in alphabetical order. Forexample, if only vertices Health and Grigg are reachable from vertex Belk, the output will looklikeBelkGriggHealthDuke...QuitThe input query quit should simply cause the program to exit without printing anything.Project HintsYou should create a Graph class, a Vertex class and an Edge class to hold the relevant vertex andweighted edge information. Use an adjacency list of edges in the vertex class.The implementation of Dijkstras algorithm is perhaps the hardest part of the project. Youmay like to first implement Dijkstras algorithm using an array as the priority queue to maintainthe vertex distances, and then implement the min binary heap to achieve the more efficient priorityqueue implementation.Remember that the initial information about the network graph will come from a file specifiedas a command-line argument. The graph you create will be a directed graph with two edges, onein each direction, for each input link. The queries will come from the standard input and theoutput from your program should go to the standard output. Example input and output files willbe posted.Grading CriteriaThe total of 100 points for this project is broken up into: 20 points for proper construction of the graph and outputting a correct description. 35 points for efficiently finding shortest paths using Dijkstras algorithm. Here 15 points arefor using a binary heap to implement the priority queue. 15 points for updating the graph based on network changes. 15 points for printing all reachable vertex sets and analyzing the complexity of your algorithm. 15 points for compilation, structure, and documentation.Within these criteria, your grade will depend on program structure, efficiency, and correct execution.The structure of your code will be judged for quality of the comments, quality of the datastructure design, and especially the logic of the implementation. The comments need not beextremely long: just explain clearly the purpose of each class and each function within each class
I want solution for the above assginment As soon as possible.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Agile Project Management With Kanban

Authors: Eric Brechner

1st Edition

0735698953, 978-0735698956

More Books

Students also viewed these General Management questions