Trail: a walk that does not repeat any edges.
Closed Trail(Circuit): a trail that begins and ends at the same vertex.
Eulerian Circuit: a circuit that includes every edge of the graph.
Eulerian Trail: a trail that includes every edge of the graph.

无向图中,图 $G$ 有欧拉回路当且仅当每个点的度数为偶数。
有向图中,图 $G$ 有欧拉回路当且仅当每个点的入度和出度相同。
无向图中,图 $G$ 有欧拉路径(非欧拉回路)当且仅当只有两个点的度数为奇数,其余都是偶数。
有向图中,图 $G$ 有欧拉路径(非欧拉回路)当且仅当只有两个点的入度和出度不同,且其中一个点的“入度 $-$ 出度=1”,另一个点的“出度 $-$ 入度=1”。

输出欧拉回路和欧拉路径的常用算法是 Hierholzer's Algorithm 和 Fleury's Algorithm,复杂度分别为 $O(E)$ 和 $O(E^2)$。

Hierholzer's Algorithm的正确性:因为一个具有欧拉回路的图G能够拆分成多个边不相交的环,因此这个算法正确。

 1 Find a circuit called $R_1$
 2 mark all edges of $R_1$
 3 i=1;
 4 while(true)
 5 {
 6     if $R_1$ contains all edges of G, then return;
 7     else
 8     {
 9         let $v_i$ be a vertex on $R_i$ that is incident with unmarked edge;
10         build a circuit $Q_i$ from $v_i$;
11         mark all edges of $Q_i$;
12         $R_{i+1} = R_i \cup Q_i$;
13         i++;
14     }
15 }
Hierholzer's Algorithm的伪代码

相关文章:

  • 2022-12-23
  • 2021-08-21
  • 2021-12-19
  • 2021-10-21
  • 2022-02-17
  • 2021-06-14
  • 2021-11-05
  • 2022-01-04
猜你喜欢
  • 2021-08-19
  • 2021-12-06
  • 2021-11-02
  • 2022-01-27
  • 2021-07-05
  • 2021-10-15
  • 2021-09-13
相关资源
相似解决方案