Jilin Province 2017 year Winter camp DAY5

Source: Internet
Author: User

DAY5 graph theory Shortest path, minimum spanning tree, topological sort, connected component, two-part graph.

In general, day5 this day of things to listen to not understand, ready to go back to the winter camp slowly understand.

The first thing to say is the adjacency matrix

If there are n points, a n*n two-dimensional array is established, and a marker on the J-bit of the I line indicates that I is connected with J.

The 2nd is the chain-forward star.

When listening to the day, listen very do not understand, and then listen to the big guy to talk about, the Internet search some information, but also understand some.

First build a _edge structure containing {to,next,val}, a head[] array, a counter tot

  

1 #define MX 100002struct  _edge3{4     int  to,next,val; 5 }EDGE[MX]; 6 int Head[mx],tot;
Code

Because the last step is to traverse from the back, so, at the time of construction, edge[tot].to points to V, the weight value W to Edge[].val, the edge[].next point to Head[u] (the last edge before the beginning), Head[u] point to Tot.

1 void Add (int u,int v,int  w)2{3     edge[ tot].to=v; 4     Edge[tot].val=W; 5     edge[tot].next=Head[u]; 6     head[u]=tot++; 7 }
code (ADD)

 

Jilin Province 2017 year Winter camp DAY5

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.