当前位置:网站首页>Introduction to topological sorting
Introduction to topological sorting
2022-07-01 13:16:00 【Cherish forever】
In graph theory , Topological sorting is a linear sequence of all vertices of a directed acyclic graph . And the sequence must satisfy the following two conditions :
Every vertex appears and only once .
If there is one from the top A To the top B The path of , So the vertices in the sequence A Appear at the top B In front of .
If it doesn't exist in the end, the penetration is 0 The node of , That means there are rings , non-existent
Concepts in topology :
Partial order : There is no loop between two vertices in a directed graph , As for connectivity , It doesn't matter .
Total order : On the basis of partial order , Any pair of vertices in a directed acyclic graph also need to have a clear relationship ( Reflected in the figure , It's a one-way connected relationship , Be careful not to connect in two directions , Then it becomes a ring ).
A simple algorithm for topological sorting : First of all, we need to find any depth of 0 A vertex of , Delete it and all adjacent edges , The finding degree is 0 The summit of , And so on , Until all vertices are deleted . The deletion order of vertices is topological sorting .
void dfs( ){
for( Adjacency point K){
if(K Not visited ){
Mark K;
DFS(K);
}
}
}
边栏推荐
- 【牛客刷题-SQL大厂面试真题】NO2.用户增长场景(某度信息流)
- Based on the open source stream batch integrated data synchronization engine Chunjun data restore DDL parsing module actual combat sharing
- c语言学习
- The 14th five year plan of China's environmental protection industry and the report on the long-term goals for 2035 Ⓖ 2022 ~ 2028
- 学历、长相、家境普通的人,未来的发展方向是什么?00后的职业规划都已经整得明明白白......
- 路由基础之OSPF LSA详细讲解
- There are risks in trading
- Zabbix 6.0 源码安装以及 HA 配置
- Vs code set code auto save
- Simple two ball loading
猜你喜欢

JS变色的乐高积木
![[Niu Ke's questions -sql big factory interview real questions] no2 User growth scenario (a certain degree of information flow)](/img/a0/e9e7506c9c34986dc73562539c8410.png)
[Niu Ke's questions -sql big factory interview real questions] no2 User growth scenario (a certain degree of information flow)

Professor Li Zexiang, Hong Kong University of science and technology: I'm wrong. Why is engineering consciousness more important than the best university?

Look at the sky at dawn and the clouds at dusk, and enjoy the beautiful pictures

Fiori 应用通过 Adaptation Project 的增强方式分享

MHA high availability cluster deployment and failover of database

终端识别技术和管理技术

Content Audit Technology

Jenkins+webhooks- multi branch parametric construction-

Wang Xing's infinite game ushers in the "ultimate" battle
随机推荐
Feign & Eureka & Zuul & Hystrix 流程
王兴的无限游戏迎来“终极”一战
Look at the sky at dawn and the clouds at dusk, and enjoy the beautiful pictures
Declare an abstract class vehicle, which contains the private variable numofwheel and the public functions vehicle (int), horn (), setnumofwheel (int) and getnumofwheel (). Subclass mot
PG基础篇--逻辑结构管理(触发器)
Zabbix 6.0 源码安装以及 HA 配置
Feign & Eureka & zuul & hystrix process
流量管理技术
一款Flutter版的记事本
Analysis report on production and marketing demand and investment forecast of global and Chinese diamond powder industry Ⓤ 2022 ~ 2027
Flow management technology
How to count the status of network sockets?
China NdYAG crystal market research conclusion and development strategy proposal report Ⓥ 2022 ~ 2028
基于mysql乐观锁实现秒杀的示例代码
Global and Chinese polypropylene industry prospect analysis and market demand forecast report Ⓝ 2022 ~ 2027
数据库之MHA高可用集群部署及故障切换
北斗通信模块 北斗gps模块 北斗通信终端DTU
How can genetic testing help patients fight disease?
Fundamentals of number theory and its code implementation
nexus搭建npm依赖私库