18 National Day map of the Hui-si School

Source: Internet
Author: User

Graph theory

1. Basic Concepts

  

  

2. Storage of graphs

  

3. Path

  

4. Free Tree

  

5 a tree and a two-fork tree

  

6. Graph traversal

  

7. Connectivity

  

8. Topology sequencing

  

9. Euler path

  

10. Shortest circuit

  

  (1) Dijkstra

  

voidDijkstraintx) { for(inti =1; I <= N; i++) Dis[i] =A[x][i]; DIS[X]=1; F[X] =1;  for(inti =1; I <= N; i++) {Minn=0;  for(intj =1; J <= N; J + +)            if(F[j] = =0&& Dis[j] >Minn) {k=J; Minn=Dis[j]; } F[k]=1; if(k = = y) Break;  for(intj =1; J <= N; J + +)            if(F[j] = =0&& Dis[k] * A[k][j] >Dis[j]) dis[j]= Dis[k] *A[k][j]; }}

  (2) Bellman-ford

Constantly adding edges in the shortest way

Complexity of Time: O (VE)

 for (int i = n; i;--i)      for (int j = n; j;--J)         = Min (Dis[v[j]], Dis[u[j]] + w[j]);

  (3) Folyd

can be considered as DP while finding the shortest path between each point pair

Complexity of Time: O (n3)

 for (int1; k <= N; + +k    )  for (int1; i <= N; + +i        )  for (int1; j <= N; + +j            ) = Min (Dis[i][j], dis[i][k] + dis[k][j]);

  (4) SPFA

Although the teacher did not say, but I usually write this ...

voidSPFA (intx) { for(inti =1; I <= N; ++i) dis[i]= MAXN, vis[i] =0; DIS[X]=0; VIS[X] =1; Q.push (x);  while(!Q.empty ()) {        inty = Q.front (); Q.pop (); Vis[y] =0;  for(inti = head[y]; I i =Net[i]) {            intt =To[i]; if(Dis[t] > Dis[y] +Cap[i]) {Dis[t]= Dis[y] +Cap[i]; if(!vis[t]) vis[t] =1, Q.push (t); }        }    }}

  (5) Johnson's right to re-empower

  

  (6) Application: Differential constraint system

  

11. Strongly Connected components

  

12. Side Double Connected components

  

13. Point Double connected components

  

14. Minimum spanning tree MST

  (1) MST basic theorem

  

  (2) MST solution method

  

//The other two will not write Qwq//this is Kruskal .structNond {intu, V, W;} E[M];intFindintx) {returnFA[X] = = x? X:FA[X] =find (Fa[x]);}BOOLCMP (Nond x, Nond y) {returnX.W <Y.W;}voidKruskal () {sort (e+1, e+k+1, CMP);  for(inti =1; I <= K; ++i) {intx = Find (e[i].u), y =find (E[I].V); if(x = = y)Continue; FA[X]=y; ++tot; Sum+=E[I].W; if(tot = = N-1) Break; }    return ;}

  (3) The nature of MST

  

15. Recent Public ancestor LCA

  (1) defining a given two points U and V, the LCA (U, v) is the deepest of all the common ancestors of two points

  (2) Seeking the law

  

18 National Day map of the Hui-si School

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.