图论算法——基本图论算法小结
·听了一天的浑浑噩噩 ·这个老师近距离看有点精致可爱,然鹅他过于强 ·老师经典语句: “来我们看一道简单题”,然鹅,是蓝题 “来我们再来看一道题",然鹅,是紫题 tql!!!tjl!!!%%%%% 一、图的入门介绍 ·什么是图?——G(graph)=(V(点),E(边)) 把图进行赋值,所赋值即为权值——点权,边权. ·图的储存 edge:next,to. eg:x——>y next:下一个以x为开头的边在数组的位置 to:y first:以x为开头的第一条边 储存方法:找到最后,在往前倒 板子: struct edge { int next, to; edge() {} edge(int _next, int _to) : next(_next), to(_to) {} } e[M]; void add_edge(int x, int y) { e[++tot] = edge(first[x], y); first[x] = tot; e[++tot] = edge(first[y], x); first[y] = tot; } int main() { for (int x = first[p]; x; x = e[x].next) { //find linkers of point p q = e[x].to; } } 升级版板子(带stl): #include