Area 1.1 : Graph Storaging
Example :
Figure 1.1 Undirected Graph
1 : matrix
The graph in Figure 1.1 will be like this
0 | 1 | 1 | 0 | 0 | 0 |
1 | 0 | 1 | 0 | 0 | 0 |
1 | 1 | 0 | 1 | 1 | 1 |
0 | 0 | 1 | 0 | 0 | 0 |
0 | 0 | 1 | 0 | 0 | 0 |
0 | 0 | 1 | 0 | 0 | 0 |
Table 1.1 : matrix storaging
In a word, if there isan edge (u, v), matrix[u][v]=matrix[v][u]=1
But, what about a directed, weighted graph?
Figure 1.2 : Directed and Weighted Graph
It will be much easier.
For an edge (u,v)=w, matrix[u][v]=w, done.
Given Score :
Difficulty : 1
x Basic Score : 26
Score : 26
[Area 1.2 Unlocked]
All Figures in the passage :
http://59.60.22.18:2500/wordpress/wp-content/uploads/2024/01/C01_Figures.zip