当前位置:网站首页>【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
边栏推荐
猜你喜欢
B端产品需求分析与优先级判断
数据库的索引和其底层数据结构
放苹果
Simple implementation of a high-performance clone of Redis using .NET (seven-end)
【Prometheus】 Grafana数据与可视化
Cholesterol-PEG-FITC, Fluorescein-PEG-CLS, Cholesterol-PEG-Fluorescein water-soluble
分析 Flink 任务如何超过 YARN 容器内存限制
SAP Product Enhancement Technology Review
Install nodejs
Ali Ermian: Do you know how to tune the JVM?
随机推荐
Some time function records commonly used in mysql
fetch请求设置请求头错误导致无法跨域
同态加密简介HE
中小企业如何实施MES管理系统
Database indexes and their underlying data structures
27岁了,目前从事软件测试,听些老一辈的人说测试前途是IT里最差的,是这样吗?
Simple implementation of a high-performance clone of Redis using .NET (seven-end)
STM32入门开发 LWIP网络协议栈移植(网卡采用DM9000)
PerfView专题 (第一篇):如何寻找热点函数
Latex引用图片 发现 显示的图片标号不对
SAP Product Enhancement Technology Review
【Mysql系列】03_系统设计
浮点型在内存中的存储
Have you encountered this kind of error? flink-sql writes to clickhouse
1.TCP/IP基础知识
Gold Transfer(树上倍增)
What is the difference between the qspi interface and the ordinary four-wire SPI interface?
[Ext JS]11.14 SimXhr.js?_dc=1659315492151:65 Uncaught TypeError problem analysis and solution
【阿克曼运动控制】
SAP 产品增强技术回顾