"Review" late-night review of the stupid graphic theory of the thing

Source: Internet
Author: User

Don't write something.

Don't want to see a jerk jump right in the back.

0. Storage structure (your mother wrote this word.

adjacency Table & Insert Edge

struct edge{    int  to,next,v;} E[M]; int Cnt,last[n]; void Insert (int A,int b,int  c) {    e[++cnt]= (Edge) {b,last[a],c} ; last[a]=cnt;} void link (int A,int b,int  c) {    insert (a,b,c); insert (b,a,c);}

1. Close your eyes and touch a spfa haha haha haha

BOOLInq[n];intDis[n];voidSPFA (intSintt) {Queue<int>Q; Inq[s]=true; FOR0 (i,n) dis[i]=inf; Dis[s]=0; Q.push (s);  while(!Q.empty ()) {        intC=Q.front (); Q.pop ();  for(intI=last[c];i;i=E[i].next) {            intv=e[i].to; if(dis[v]>dis[c]+e[i].v) {Dis[v]=dis[c]+e[i].v; if(!Inq[v])                    {Q.push (v); INQ[V]=true; }}} Inq[c]=false; }}

2.Tarjan • Every writing must be wrong · Shrinking loop algorithm

intScc,ind;intBel[n],ins[n],low[n],dfn[n];stack<int>s;voidTarjan (intv) {Low[v]=dfn[v]=++IND; S.push (v); Ins[v]=true;  for(intI=last[v];i;i=E[i].next) {        if(!dfn[e[i].to]) Tarjan (e[i].to), Low[v]=min (low[v],low[e[i].to]); Else    if(Ins[e[i].to]) Low[v]=min (low[v],dfn[e[i].to]); }     intnow=-1; if(dfn[x]==Low[x]) {        ++SCC;  while(now!=x&&!S.empty ()) {            intt=s.top (); S.pop (); Ins[t]=false; Bel[t]=SCC; }    }}

If anyone finds out this is wrong, tomorrow's a snack.

Here's the ejection mark.

Let's start with a little bit of tree-related stuff.

3.

LCA: Based on multiplication: ...

Based on RMQ: The two-point LCA is the most shallow node in the two-point DFS sequence. Well, then we just need to use the algorithm of the most valued query.

"I feel like my IQ is down.

4. Matrix Tree theorem

Non-graph Spanning tree count

Pre-Knowledge: Gaussian elimination, determinant

We construct a degree matrix D d (i,j) equal to the degree of I at i!=j, otherwise equal to 0

Constructs an adjacency matrix A

And then this diagram of the Kirchhoff (this name?) The matrix is g,g (i,j) =d (I,J)-A (I,J)

Then we calculate the determinant value, which is the number of spanning tree of this graph.

What time do you write tomorrow?

"Review" late-night review of the stupid graphic theory of the thing

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.