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
1 ImportJava.text.DecimalFormat;2 ImportJava.text.NumberFormat;3 Importjava.util.ArrayList;4 Importjava.util.Arrays;5 Importjava.util.Collection;6 Importjava.util.Collections;7 Importjava.util.List;8 ImportJava.util.Scanner;9 ImportJava.util.Stack; Ten Public classmain{ One Public Static voidMain (string[] args) { AScanner input =NewScanner (system.in); - intn =input.nextint (); - intm =input.nextint (); the int[] A =New int[n][m]; - for(inti=0;i<m;i++){ - intb =input.nextint (); - intc =input.nextint (); +A[b-1][i] = 1; -A[c-1][i] = 1; + } A for(inti=0;i<n;i++){ at for(intj=0;j<m;j++){ -System.out.print (a[i][j]+ ""); - } - System.out.println (); - } - in } -}
Algorithm Training Correlation Matrix