图论技巧

https://leetcode.cn/problems/find-edges-in-shortest-paths/description/

https://cp-algorithms.com/graph/breadth-first-search.html
oiwiki是翻译上面文章的
https://oi-wiki.org/graph/bfs/#双端队列-bfs
image

正反两次dijkstra

https://leetcode.cn/problems/find-edges-in-shortest-paths/description/
https://www.luogu.com.cn/problem/P2865

奇偶最短路

给n个点m条边无向图,每次询问两个点之间是否有长度为d的路径(不一定是简单路径)
分层图拆点
https://www.cnblogs.com/LYqwq/articles/solution-p3556.html
https://blog.csdn.net/qq_42110318/article/details/83688108

https://www.cnblogs.com/yinyuqin/p/11997763.html

https://www.acwing.com/solution/content/63321/
https://www.acwing.com/solution/content/6409/

https://oi-wiki.org/graph/node/
拆点有2种写法, 一种是扩展状态,一种直接建图加边?

https://www.luogu.com.cn/article/iteu0ot4

图论的小技巧以及扩展

反向建边

虚点连边

拆点构图

图论中要注意的

  1. 先看眼是有向图还是无向图,无向图数组开两倍。

  2. 如果题目中没有声明无自环和重边,需要注意

  3. 有些遍历的题要考虑环,否则可能死循环,可以使用缩点

  4. 如果题目中边权小于等于零,要考虑负环、零环的情况

  5. 跑最短路的时候要赋初值。

  6. 关于 Spfa ,能不用还是不用吧,毕竟容易被卡。

posted @ 2025-05-08 18:01  katago  阅读(21)  评论(0)    收藏  举报