图论

对于图的建立 利用vector ,其他方法,用到必须使用的情况在说。

struct edge{
    int d,w;
    edge(){ }
    edge(int a,int b){d=a,w=b;}
   bool    operator  <(const edge &t)const     
    {
        if(w==t.w) return d<t.d;
        return w<t.w;
    }
};
vector <edge> p[M];
int add(int a,int b,int c)
{
    edge t=edge(b,c);
    p[a].push_back(t);
    t=edge(a,c);
    p[b].push_back(t);
}
图的建设

特别小心的地方: 

  对于第一个点 一定要特别标记,不然会错;

 

原文地址:https://www.cnblogs.com/Lamboofhome/p/15426296.html