当前位置:网站首页>[learning notes] shortest path + spanning tree
[learning notes] shortest path + spanning tree
2022-06-28 08:14:00 【Ants looking up at the stars】
Difficult subject
Opening Portals
Good question !
We call the portal the key point .
Let the distance between any two keys be dist(i,j) , Considering the nature of the transmission , All you need is a spanning tree that connects all the key points , And then traverse from any key point , Exactly the sum of the edge weights of the spanning tree .( It's a little twisted )
If we start at each key point dijkstra , The time complexity is O ( n 2 log n ) O(n^2\log n) O(n2logn) .
For this model , We have a Multi source shortest path Algorithm :
- Start with each key , Find the shortest distance to each point
- Consider enumerating an edge (u,v,w) , Connect the two keys closest to the two endpoints of this edge :( It is equivalent to enumerating transit points )

The correctness is obvious .
Specially ,MST That is, every point is a key point .
Of course , An edge may be computed multiple times on the spanning tree .

Complete the MST
This problem does not require a sophisticated algorithm . Direct recklessness
You can run the complete graph directly MST , Then find a small spanning tree ( Just discuss it separately ) .
Jumping Around
boruvka Board questions
Trial for Chief
What a delicate little structure !
I never thought it was the shortest circuit !
Consider from (i,j) set out , The distance between adjacent grids with different colors is 1 , The distance between grids with the same color is 0 , Find the farthest black grid , The answer for dist+1 .( Special judgment: all white )
Consider its meaning . Equivalent to alternating black and white , Operate greedily .
Flights
Cuckoo ...
Difference constraint + shortest path !!

Capitalism
Wonderful topic !
First, it is judged that the odd ring must have no solution .
The picture of this problem is very special , Because it's a two-way side , Therefore, starting from any point of the connected block, you can reach other points . So let's enumerate S As a starting point , Run differential constraint .

What happens is that there will be no edge connected dis[u]=dis[v] The situation of , Otherwise, odd rings will appear .
In this way, we can get the solution of a combination method .
Then, the maximum range must be satisfied .
Cannot build super origin .qwq
边栏推荐
- cuda和cudnn和tensorrt的理解
- asp. Net registration page
- Dataset filling data, and the use of rows and columns
- 安装nrm后,使用nrm命令报错internal/validators.js:124 throw new ERR_INVALID_ARG_TYPE(name, ‘string‘, value)
- 图像翻译:UVCGAN: UNET VISION TRANSFORMER CYCLE-CONSISTENT GAN FOR UNPAIRED IMAGE-TO-IMAGE TRANSLATION
- Airflow2.1.1 summary of the pits stepped on in actual combat!!
- Airflow2 configuration windows azure SSO details based on oauth2 protocol
- SOC clock configuration
- [JS] - [throttling and anti shake function]
- MySQL row format parsing
猜你喜欢
随机推荐
Resolution of Rac grid failure to start after server restart
Introduction, compilation, installation and deployment of Doris learning notes
Introduction to Devops Basics
MySQL row format parsing
MySQL implements transaction persistence using redo logs
Dataset filling data, and the use of rows and columns
同花顺注册开户靠谱吗?安全吗?
Redis persistence problem and final solution
你了解TCP協議嗎(二)?
Oracle RAC -- understanding of VIP
How redis solves cache avalanche, breakdown and penetration problems
关于在cmd中MySQL不能插中文数据的原因
js运算符的优先级
【学习笔记】线性基
匿名页的反向映射
城联优品向英德捐赠抗洪救灾爱心物资
ROS notes (09) - query and setting of parameters
Is it reliable for the top ten securities companies to register and open accounts? Is it safe?
Redis uses sentinel master-slave switching. What should the program do?
Uvcgan: unt vision transformer cycle-consistent Gan for unpropared image-to-image translation









