For this assignment your program should accept a file as


Assignment

For this assignment, your program should accept a file as input. First line in the input file contains the label of the source node. Then each subsequent line has the edges of a directed graph. Nodes are labeled as integers from 1 to 500 (maximum 500 nodes). Each row indicates an edge, the node label in first column is the tail and the node label in second column is the head. For example, the 2nd row looks Mot "1 2". This means the node with label 1 has an outgoing edge to the node with label 2.

Your task is to write a code (using BFS or DFS) to compute the shortest path between a source note,to all other nodes. Your output should contain the label for each node, and the shortest distance to that node from the source. For example, first row in the sample output indicates that the shortest distance from source node to node 2 is 1. And the last line indicates that the shortest path from source node to node 6 is 4.

Solution Preview :

Prepared by a verified Expert
Data Structure & Algorithms: For this assignment your program should accept a file as
Reference No:- TGS01693335

Now Priced at $35 (50% Discount)

Recommended (93%)

Rated (4.5/5)