Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int num_of_nodes;
- printf("Enter the Number of NODE: " );
- scanf("%d",&num_of_nodes);
- int i,j,graph[50][50],temp[50][50];
- int number_of_edges=0;
- for(i=0;i<num_of_nodes;i++)
- {
- for(j=0;j<num_of_nodes;j++)
- {
- if(i!=j)
- {
- graph[i][j]=rand()%2;
- temp[i][j]=rand()%2;
- }
- else
- {
- graph[i][j]=0;
- temp[i][j]=0;
- }
- }
- }
- for (i=0;i<num_of_nodes;i++)
- {
- for (j=0;j<num_of_nodes;j++)
- {
- if(temp[i][j]==1)
- {
- temp[j][i]=0;
- }
- printf("%d ", graph[i][j]);
- }
- printf("\n");
- }
- for(i=0;i<num_of_nodes;i++)
- {
- for(j=0;j<num_of_nodes;j++)
- {
- if(temp[i][j]==1){
- number_of_edges++;
- }
- }
- }
- printf("Number Of Edges = %d\n", number_of_edges);
- }
Advertisement
Add Comment
Please, Sign In to add comment