ACM模板——链式前向星&&邻接表存图

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define maxn 100501
 4 
 5 int ver[maxn],Next[maxn],head[maxn],val[maxn];
 6 int tot = 0; 
 7 void add(int x,int y,int w)
 8 {
 9     ver[++tot] = y,Next[tot] = head[x],head[x] = tot,val[tot] = w;
10 }
11 int main()
12 {
13     for(int i = head[x]; i; i = Next[i])
14     {
15         int y = ver[i];
16         int w = val[i]; 
17         //i为边的hash值, 接下来可以对x -> y 权为w的边进行操作 
18     }
19     return 0;
20 }
链式前向星

 

posted @ 2019-09-07 09:26  Asurudo  阅读(217)  评论(0编辑  收藏  举报