0 1
2 3
0 1 2 3
0 0 1 1 0
1 0 0 0 0
2 0 1 0 1
3 0 1 0 0
1. Insert the graph in a two dimensional array.
For(i=0; i<n; i++)
For(j=0; j<n; j++)
Scanf(“%d”,&gr[i][j])
2. Find the indegree and outdegree of a given node.
Input:
Node: 2
Output:
Indegree of 2 is 1 and outdegree of 2 is 2.
3. Find any self-loop in the graph.
4. Find whether there is a direct edge between two node:
Input:
Node 1: 2
Node 2: 3
Output:
Yes