*in the given problem i need mainly Implement forward star graph representation*
Write a C program to compute shortest path between two given nodes for an unweighted undirected connected graph.
You should implement the following:
1. Implement forward star graph representation
2. Use bfs to compute the shortest path (you should use the forward star representation that you have implemented in the BFS)
3. Write a test function which reads number of vertices, number of edges, the sequence of edges followed by source and destination vertices from stdin.
Sample Input/Output: (for K4 - complete graph on 4 vertices, vertex index starts from 0)
Input: 4 6 0 1 0 2 0 3 1 0 1 2 1 3 2 0 2 1 2 3 3 0 3 1 3 2 0 3
Output: 1
You should print "INVALID INPUT" for all invalid input cases.
Comments
Leave a comment