Fleury算法的时间复杂度

发布于 2024-08-24 04:26:25 字数 42 浏览 3 评论 0原文

您能帮我找出 Fleury' 算法(用于获取欧拉电路)的时间复杂度吗?

Could you please help me find out the time complexity of the Fleury' algorithm (which is used to get the Eulerian circuit)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

書生途 2024-08-31 04:26:25

在您指定如何识别桥边缘之前,Fleury 的算法并不是真正完整的。 Tarjan 给出了用于识别所有桥梁的线性时间算法(参见 http://en.wikipedia.org /wiki/Bridge_(graph_theory) ),因此在每个删除的边之后重新运行 Tarjan 算法的简单实现将是 O(E^2)。可能有更好的方法来重新计算桥集,但也有更好的 O(E) 算法。 (参见http://www.algorithmist.com/index.php/Euler_tour#Fleury .27s_algorithm;不是我的网站:))

Fleury's algorithm isn't really complete until you specify how the bridge edges are identified. Tarjan gave a linear-time algorithm for identifying all bridges (see http://en.wikipedia.org/wiki/Bridge_(graph_theory) ), so a naive implementation that reran Tarjan's algorithm after each deleted edge would be O(E^2). There are probably better ways to recompute the set of bridges, but there is also a better O(E) algorithm. (See http://www.algorithmist.com/index.php/Euler_tour#Fleury.27s_algorithm ; not my site :))

回忆那么伤 2024-08-31 04:26:25

这里:

你可以读到它是 O(E),线性边缘计数。

Here:
http://roticv.rantx.com/book/Eulerianpathandcircuit.pdf
you can read among other things, that it is O(E), linear edge count.

兮颜 2024-08-31 04:26:25

Fleury 算法涉及以下步骤:

  1. 确保图有 0 或 2 个奇数顶点。

  2. 如果有 0 个奇数顶点,则从任意位置开始。如果有 2 个奇数顶点,则从其中之一开始。

  3. 一次跟随一个边。如果您可以在桥式和非桥式之间进行选择,请始终选择非桥式。

  4. 当你用完边缘时停止。

如果通过 Tarjan 算法找到了桥,并且将这些桥存储在邻接矩阵中,那么我们不需要每次都运行 Tarjan 算法来检查一条边是否是桥。我们可以在 O(1) 时间内检查所有其他桥接查询。因此,Flury 的算法时间复杂度可以降低到 O(V+E) {因为这是 DFS},但该方法需要 O(V2) 额外空间来存储桥。

Fleury algorithm involves following steps :

  1. Make sure the graph has either 0 or 2 odd vertices.

  2. If there are 0 odd vertices, start anywhere. If there are 2 odd vertices, start at one of them.

  3. Follow edges one at a time. If you have a choice between a bridge and a non-bridge, always choose the non-bridge.

  4. Stop when you run out of edges.

If bridges are found out by Tarjan's algorithm and these bridges are stored in an adjacency matrix then we need not run tarjan's algorithm every time to check whether an edge is a bridge or not. We can check it in O(1) time for all other bridge queries. Thus Flury's algorithm time complexity can be reduced to O(V+E) {as this is a DFS} but this method needs O(V2) extra space to store bridges.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文