存储 邻接矩阵 12345 void (int u,int v,int w){ G[a][b]=c;} 邻接表 123456789 void (int u,int v,int w){ tnt++; next[tnt]=first[u]; first[u]=tnt; weight[tnt]=a; end[tnt]=j;} 遍历 深度优先 12345678 void DFS(int u){ if(vis[u]) return ; vis[u]=true; for(int e=first[u];e;e=next[e]) DFS(end[e]);} 赞微海报分享
近期评论