directed-acyclic-graphs - 拓扑排序:图
问题描述
我看了一个关于拓扑排序的类似问题,但仍然不确定这个概念。
有一些我不确定的问题。
Assuming the DFS visits adjacent nodes in alphabetical order, nd a topological order of
the nodes v 2 V by running the DFS on this DAG G from the source (zero in-degree)
node.
对于以下,我得到了(a,d,c,e,b,f)的拓扑顺序。这会是正确的拓扑排序吗?
解决方案
好吧,拓扑排序可以有多个correct
排序,而您拥有的排序是正确的。要记住的是,for every directed edge uv from vertex u to vertex v, u comes before v in the ordering
所以在你的图表中,考虑边 a->c(a 必须在 c 之前)c->e(c 必须在 e 之前)e->f(e 必须在 f 之前)和很快。
推荐阅读
- python - 每天累积x英寸需要多少天?
- apache-kafka - 合并的kafka流的序列化错误
- pascal - 在 Object pascal 中计算字符串中的不同字符
- javascript - 为什么我的 Bootstrap 手风琴不能正常工作?
- python-3.x - 使用 cython 时出错“致命错误 C1083;无法打开包含文件:'io.h':没有这样的文件或目录”
- swift - 在 Swift 中异步合并两个字典
- c++ - 如何将int转换为字符串?
- angular - Nativescript - 装饰器不支持错误函数调用,但调用了“NativeScriptRouterModule”
- java - 如何使用 Spring Boot 将 @Cacheable 与 redis 一起使用
- nginx - 反向代理到两个单独的 nginx 实例