数组模拟实现邻接表
来源:互联网 发布:云计算 大事件 编辑:程序博客网 时间:2024/06/05 00:47
之间都是用vector模拟邻接表,但是后面发现vector时间复杂度有点高,所以写了份用数组模拟链表的方法实现邻接表
#include<iostream>#include<cstdio>#include<cstring>using namespace std;/******************/#define LL long longconst int maxn=100010;template<int N,int M>struct Graph{ int top; struct Vertex { int head; }V[N]; struct Edge { int v,next; }E[M]; void init() { memset(V,-1,sizeof V); top=0; } void add_edge(int u,int v,int w) { E[top].v=v; E[top].next=V[u].head; V[u].head=top++; }};Graph<maxn,maxn> g;int main(){ int n,m; while(~scanf("%d%d",&n,&m)) { g.init(); } return 0;}
0 0
- 数组模拟实现邻接表
- 数组模拟邻接表
- 【邻接表】数组模拟邻接表
- 用数组模拟邻接表
- 用数组模拟邻接表
- 使用数组模拟邻接表
- hash 链地址法+ 数组模拟邻接表实现
- 数组实现邻接表
- 邻接表数组实现
- poj 3013(数组模拟邻接表+spfa)
- 迪杰斯特拉--数组模拟邻接表优化
- /*用数组模拟邻接表 超时×/
- 用数组模拟邻接表 hdu2647
- SPFA的两种实现形式(二维数组与数组模拟邻接表)
- 邻接表的数组实现
- 邻接表(数组实现)
- 邻接表的数组实现
- 用数组实现邻接表
- JVM内存结构浅析
- Android Studio安装记录
- vim+go配置
- [ASP.NET MVC 小牛之路]12 - Section、Partial View 和 Child Action
- bzoj 3503(解异或方程组)
- 数组模拟实现邻接表
- JVM——垃圾回收机制入门
- [ASP.NET MVC 小牛之路]13 - Helper Method
- Javascript中关于跨域访问的学习笔记
- 9.04考试总结
- [ASP.NET MVC 小牛之路]14 - Unobtrusive Ajax
- Zsh简介与使用
- SCU2016-01 I题 二分 + 斜率优化dp
- 深入浅出struts2(二)