建邻接表喽~~~

写个类,以后到这里找就行。^_^

const int M = 5024;

struct node {
    int to;
    int val;
    int next;
} g[N<<1];

class Graph {
public:
    int head[M], t;

    void init() {
        CL(head, 0XFF); t = 0;
    }

    void add(int u, int v, int w) {
        g[t].to = v; g[t].val = w; g[t].next = head[u];
        head[u] = t++;
    }
} G;

 

 

posted @ 2012-08-24 09:02  AC_Von  阅读(178)  评论(0编辑  收藏  举报