ADJACENT MATRIX
This usually used in representation of graphs.If there are n vertices in graph then there are n rows and n columns in matrix. Let us take Ith row and Jth column then A[I][J] represents the edge between two nodes I & J.If a[I][J] == 0 then there is no edge between node I and node J & if A[I][J] == 1 then there is edge. These type of graph representation is used when there are more number of edges.Reason is that if there are e less number of edges then lot of space will wasted in storing the zeroes which is not good thing. Following is the graph and its adjancy matrix => # include < stdio.h > # include < stdlib.h > int main () { // n is number of edges int n ; printf (" Enter the number of edges => "); scanf (" %d ", & n ); // construct adjancy matrix int adjMatrix [ n + 1 ][ n + 1 ]; // iterate for status of connect...

Comments
Post a Comment