You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
605 B
21 lines
605 B
### 有向图求拓扑序
|
|
|
|
* 求拓扑序有$dfs$和$bfs$两种方法。
|
|
* 在求拓扑序过程中,可以增加判断是否有环的代码。
|
|
* 有些题目中,单独采用$bfs$或$dfs$只为了判断是否有环,而不是要输出拓扑序,这时代码可以适当简化。
|
|
|
|
### 有向图判环
|
|
|
|
**例题**:
|
|
[$HDU$ $3342$ $Legal$ $or$ $Not$](http://acm.hdu.edu.cn/showproblem.php?pid=3342)
|
|
|
|
### 1、$bfs$判环
|
|
|
|
### 2、$dfs$判环
|
|
|
|
### 3、强连通分量判环
|
|
https://www.cnblogs.com/ljy-endl/p/11562352.html
|
|
|
|
### 拓扑序的应用
|
|
https://www.jianshu.com/p/1cda977685b6
|