【发布时间】:2017-08-27 13:40:25
【问题描述】:
以下是在欧拉图中找到欧拉路径的给定算法。但是,据说有一个顶点少于10个的反例。给定的欧拉图是无向的,每个顶点的度数都是偶数,并且会在同一个顶点开始和结束。
1. Perform a DFS traversal of G and number the vertices in DFS-preorder.
2. Re-initialize all vertices and edges of G as unused.
3. Produce a cycle as follows:
Start from the vertex with preorder number 1 (computed in step 1), and
repeatedly go to the vertex with highest preorder number possible along
an unused edge.
Stop when all edges incident to the current vertex are used.
在过去的 3 天里,我一直在尝试从 6 到 9 的顶点,但我真的想不出一个例子。任何帮助表示赞赏!谢谢。
【问题讨论】:
-
是什么让你认为有反例? “欧拉图”是指具有欧拉路径还是欧拉环的图?
-
@Codor 感谢您的回复。通过欧拉图,这意味着每个顶点都有一个偶数。应该有一个反例,因为提示说反例的顶点少于 10 个。
-
好的,那我想知道是什么让你认为有一个反例;如果每个顶点的度数相等,我相信,无论邻居的偏好如何,都不会卡住。
-
嗯,有有卡住的机会;这个问题很有趣——到目前为止,我还没有想出一个反例。太神奇了。
-
如果我错了,请纠正我,但不会为 A ---- B \ / C / \ D ---- E 使用 DFS-
C A B D E现在C是节点号 1 我们将从它开始,并且必须再次访问它才能进入另一个循环。如果我对您的代码的理解是正确的,则具有 2 个或更多周期的公共节点的类似示例将给出错误。
标签: graph-algorithm depth-first-search pseudocode euler-path