Programming Assignment 1
Deadline: 21/02/2020
Deadline: 21/02/2020
General instructions:
Input: Let's assume the input will be read from a text file. The first line should contain the number of vertices (n) and the starting vertex for breadth first traversal. Thereafter, there would be n lines for specifying the neighbours of vertices 1 to n (in that order).
Sample Input/Output Example: (Path on 4 vertices)
4 2
2
1 3
2 4
3
Output:
Stating vertex followed by the trace of BFS
Example:
2 1 3 4
Input: The first contains the number of vertices. From 2nd line onwards, the i^th line has vertices adjacent to vertex (i-1).
Example: (Path on 4 vertices)
4 2
2
1 3
2 4
3
Output:
1) No (if the input graph has no cycles)
2) Yes (if input graph has a cycle along with one cycle). Print vertices on the cycle.
Input: The first line has the number of vertices (n). From 2nd line onwards, the i^th line has vertices adjacent to vertex (i-1)
Example: (Path on 4 vertices)
4 2
2
1 3
2 4
3
Output:
1) Yes (if the instance is a bipartite graph). Print the vertices belonging to the bi-partitions in parenthesis.
Example:
Yes (1 3) (2 4)
2) No (if the graph is not bipartite). Print any witness to show that the graph is not bipartite.