CSD201 Repair Practical Test Graph
CSD201 Repair Practical Test Graph
BFS traversing
Write a program to build an undirected graph by giving edge list.
Giving a start vertex, your task is showing the BFS (Breadth First Traversal) traversing of the
undirected graph.
For example,
Giving the edge list that used to represent undirected graph as follow:
8 10 0
0 1
0 2
0 5
1 6
2 3
2 4
3 4
4 5
4 6
5 7
Figure 1. The undirected graph that created by giving adjacency matrix
8 10 0 0,1,2,5,6,3,4,7
0 1
0 2
0 5
1 6
2 3
2 4
3 4
4 5
4 6
5 7
8
0 5 3 0 0 11 0 0
5 0 5 0 0 0 7 11
3 5 0 11 1 7 0 0
0 0 11 0 11 0 11 0
0 0 1 11 0 1 5 7
11 0 7 0 1 0 0 42
0 7 0 11 5 0 0 42
0 11 0 0 7 42 42 0
The MST is shown as figure 4 and the weight of minimum spanning tree is 33: