
c++ code using text file as input
Read the Graph.txt file to create an adjacency matrix or list.Graph.txt represents an
undirected graph. After creating the matrix/list traverse the graph by implementing the BFS
algorithm given above. You should print the distance (or hop) from the source and also the path
from source. [Assume 1 is the root node]
Sample Graph.txt File (Numbering starts from 1):
6 [# of nodes]
[Edges]
1 2
1 3
2 1
2 4
2 5
3 1
3 5
4 2
4 5
4 6
5 2
5 3
5 4
5 6
6 4
6 5
0%
to see other 2 answers
Related documents
Search questions by subject