当前位置:网站首页>【Study Notes】Unused graph theory knowledge
【Study Notes】Unused graph theory knowledge
2022-08-11 10:53:00 【OneInDark】
斯坦纳树
不看 c 9 \sf c9 c9 I didn't even know there was such a thing.It is true that the food has reached a certain level.
目标是,In an undirected graph with nonnegative edge weights,Select the connected subgraph with the minimum edge weight and minimum,使得 k k k a given point in the graph.Obviously only trees will be selected,Trees have roots.于是可以 d p \tt dp dp,记 f ( x , S ) f(x,S) f(x,S) 为 x x x Connect the rooted tree S S S The minimum cost of keypoints within .
The root has only one son f ( x , S ) ← f ( y , S ) + w ( x , y ) f(x,S)\gets f(y,S)+w(x,y) f(x,S)←f(y,S)+w(x,y),There are multiple sons f ( x , S ) ← f ( x , T ) + f ( x , S ∖ T ) ( T ≠ ∅ , T ⫋ S ) f(x,S)\gets f(x,T)+f(x,\;S\setminus T)\;(T\ne\varnothing,\;T\subsetneqq S) f(x,S)←f(x,T)+f(x,S∖T)(T=∅,T⫋S) .
转移顺序,Obviously follow ∣ S ∣ |S| ∣S∣ 升序.或者按照 S S S 升序,in the binary value sense.Then it is easy to do the second type of transfer,Subset enumeration.
The first type of transition is the shortest-path transition,可以直接 dijkstra \texttt{dijkstra} dijkstra 等.
Card often:应让 S S S is the first dimension of the array,In this way, the memory access in the shortest time is very continuous.同时,The second type of transfer should also be enumerated first T T T 再枚举 i i i .
最小直径生成树
Enumerates the midpoint of the diameter,Then the answer is its furthest distance to all points multiplied by it 2 2 2 .If that's not the midpoint,The value is too large.
So just find the midpoint of the graph,i.e. minimize its furthest distance to all points.
Find the shortest path to all sources,Then find the best point on each edge.是个 O ( n ) \mathcal O(n) O(n) Piecewise function,每段的 min \min min 易求.复杂度 O ( n m ) \mathcal O(nm) O(nm) .
最小树形图
目标是,on a weighted directed graph,Find the subgraph that satisfies the edge weights and the smallest sum r r r There is a unique path to each point(That is, a tree diagram).It doesn't matter whether the frontier rights are non-negative or not,Because adding big positive numbers to all sides is enough.
Because it is more like a minimum spanning tree,所以可以贪心.有点不自然?But the logic is relatively strict.This is called the Zhu Liu algorithm.
The dendrogram is equivalent to giving except r r r Each point of , selects the incoming edge,Make the graph acyclic.因此,给 r r r Points other than the least weighted edge are selected,If this can form a treemap,That must be the best solution.
否则(There is an optimal solution such that )There must be exactly one edge on the ring not selected.Because one side is not selected,Description cannot be adjusted,Shows that the points on both sides have the opposite reachability relation to this edge;Uncheck if there are at least two edges on the ring,A circular reachability relationship can be derived,矛盾.
So the ring can be reduced to a single point,The outside-to-inward edge becomes to replace the original incoming edge,That is, the edge weight of the original incoming edge is subtracted.This new single point also selects only one incoming edge,i.e. replace an edge,符合预期.
At least one point can be reduced per round(Not all points are in the ring,There may be only two points in the loop,The rest of the points form a dendrogram),总复杂度 O ( n m ) \mathcal O(nm) O(nm),The actual operation should run unsatisfactory.
还有个 tarjan \textsf{tarjan} tarjan 算法.Make all points oriented r r r 的连边,边权为 + ∞ +\infty +∞,It is not difficult to verify that this process is correct:维护一个栈,Initially there are arbitrary points in it a a a,Remove the top of the stack and its smallest incoming edge each time,Select the incoming edge.If the selected incoming edges form a ring,Apparently some points at the top of the stack,缩点(The new point remains on top of the stack),Continue this process until only one point remains in the entire graph.
Use union search to deal with shrink points,Use can be stacked(带标记)It is enough to maintain the entry edge of each point.复杂度 O ( m log m ) \mathcal O(m\log m) O(mlogm) .
Comment. 奶奶滴,Why I figured out the complexity and OI-wiki \text{OI-wiki} OI-wiki It's written differently
边栏推荐
猜你喜欢

The mathematical knowledge required for neural networks, the mathematical foundation of neural networks

openresty概述及Lua语言的嵌入

放苹果

Database indexes and their underlying data structures

SAP 产品增强技术回顾

chrome无痕浏览模式中使用插件

【翻译】Drafting and Revision: Laplacian Pyramid Network for Fast High-Quality Artistic Style Transfer

【中央任务调度系统—通信开发】

Qihua stores the future and interprets the origin of distributed

PerfView专题 (第一篇):如何寻找热点函数
随机推荐
LeetCode · Question of the Day · 1417. Reformatting String · Simulation
MySQL表sql语句增删查改_增加
【Mysql系列】03_系统设计
虚拟机使用 WinSCP & Putty
Incredible, thanks to this Android interview question, I have won offers from many Internet companies
STM32入门开发 LWIP网络协议栈移植(网卡采用DM9000)
Some time function records commonly used in mysql
【综合练习12】实现静态网页的相关功能
03列中新增子行
chrome is set to dark mode (including the entire webpage)
[Ext JS]11.14 SimXhr.js?_dc=1659315492151:65 Uncaught TypeError problem analysis and solution
MySQL表sql语句增删查改_修改_删除
PerfView专题 (第一篇):如何寻找热点函数
LeetCode·每日一题·1417.重新格式化字符串·模拟
a sequence of consecutive positive numbers with sum s
【UOJ 454】打雪仗(通信题)(分块)
Jetpack Compose学习(9)——Compose中的列表控件(LazyRow和LazyColumn)
OAK-FFC Series Product Getting Started Guide
【翻译】Drafting and Revision: Laplacian Pyramid Network for Fast High-Quality Artistic Style Transfer
SDUT数据库 SQL语句练习(MySQL)