Blue Bridge Cup _ Algorithm training _ Correlation matrix

Source: Internet
Author: User

This topic first we need to know what the correlation matrix is:

This is the definition of the association matrix found on the internet, the personal feeling is still relatively clear.

Well, the next step is to make the output of the matrix based on the given data.

The problem is given to the graph, the definition is the non-direction diagram. The difference between the two should be able to think, there is a direction graph has the starting and ending coordinates, the order is not reversed, which is also described in the topic. Next is the arrow from the starting point, which is reflected in the matrix as 1, the point pointed to, and reflected in the matrix as-1. Understand this we are good to operate:

1#include <iostream>2 using namespacestd;3 intMain ()4 {5     intn,m;6     inta[ -][ +]={0};7     intx1,x2;8Cin>>n>>m;9      for(inti =0; I < m; i++)Ten     { OneCin>>x1>>x2; Ax1--; -x2--; -A[x1][i] =1; theA[x2][i] =-1; -     }  -      for(inti =0; I < n; i++) -     { +          for(intj =0; J < M; J + +) -         { +cout<<a[i][j]<<" "; A         } atcout<<Endl; -     } -      -     return 0; -}

The x1--and x2--in the middle of the code, because our array is starting from 0, but the node is not 0, this should be noted.

Blue Bridge Cup _ Algorithm training _ Correlation matrix

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.