以下是寻找欧拉图的欧拉路径的算法。然而,据说存在一个小于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.
在过去的三天里,我一直在尝试使用6到9个顶点,但真的找不到一个例子。感谢任何帮助!谢谢。
D ---- E 使用DFS-
C A B D E
现在由于C
是节点1,我们将从它开始,并且必须再次访问它才能进入其他循环。 如果您的代码理解正确,具有2个或多个公共节点的类似示例将导致错误。 - monster