The problem description has a forward graph of n nodes m edges, please output his correlation matrix. Input format the first line two integers n, m, indicating the number of nodes and edges in the graph. n<=100,m<=1000.
Next m line, two integers a, b for each line, indicates that there are (b) edges in the diagram.
Note that the image may contain a heavy edge, but there is no self-loop. Output format output the graph's correlation matrix, and be careful not to change the order of edges and nodes. Sample Input 5 9
1 2
3 1
1 5
2 5
2 3
2 3
3 2
4 3
5 4 Sample Output 1-1 1 0 0 0 0 0 0
-1 0 0 1 1 1-1 0 0
0 1 0 0-1-1 1-1 0
0 0 0 0 0 0 0 1-1
0 0-1-1 0 0 0 0 1
#include <stdio.h>intMain () {intg[101][1001],n,i,j,m,x,y; scanf ("%d%d",&n,&m); for(i=1; i<=n;i++) { for(j=1; j<=m;j++) G[i][j]=0; } for(i=1; i<=m;i++) {scanf ("%d%d",&x,&y); G[x][i]=1; G[y][i]=-1; } for(i=1; i<=n;i++) { for(j=1; j<=m;j++) { if(j!=m) printf ("%d", G[i][j]); Elseprintf ("%d", G[i][j]); } printf ("\ n"); } return 0;}
Algorithm Training Correlation Matrix