Graph | Eulerian path
In graph theory, a Eulerian trail (or Eulerian path) is a trail in a graph which visits every edge exactly once. Similarly, an Eulerian circuit or Eulerian cycle is an Eulerian trail which starts and ends on the same vertex.
Hierholzer's algorithm 可以在O(E)的时间下给出解。
算法:
- Choose any starting vertex v, and follow a trail of edges from that vertex until returning to v. It is not possible to get stuck at any vertex other than v, because the even degree of all vertices ensures that, when the trail enters another vertex w there must be an unused edge leaving w. The tour formed in this way is a closed tour, but may not cover all the vertices and edges of the initial graph.
- As long as there exists a vertex u that belongs to the current tour but that has adjacent edges not part of the tour, start another trail from u, following unused edges until returning to u, and join the tour formed in this way to the previous tour.
当然,需要用到双向链表不断地把边删掉,如果最终所有边都被访问了,那么就可以退出了。但是如果找不到点继续扩展,而且边又还有的话,那么就说明给不出回路。
Graph | Eulerian path的更多相关文章
- PAT1126:Eulerian Path
1126. Eulerian Path (25) 时间限制 300 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue In grap ...
- A1126. Eulerian Path
In graph theory, an Eulerian path is a path in a graph which visits every edge exactly once. Similar ...
- PAT A1126 Eulerian Path (25 分)——连通图,入度
In graph theory, an Eulerian path is a path in a graph which visits every edge exactly once. Similar ...
- 1126 Eulerian Path (25 分)
1126 Eulerian Path (25 分) In graph theory, an Eulerian path is a path in a graph which visits every ...
- PAT甲级 1126. Eulerian Path (25)
1126. Eulerian Path (25) 时间限制 300 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue In grap ...
- PAT 甲级 1126 Eulerian Path
https://pintia.cn/problem-sets/994805342720868352/problems/994805349851185152 In graph theory, an Eu ...
- PAT 1126 Eulerian Path[欧拉路][比较]
1126 Eulerian Path (25 分) In graph theory, an Eulerian path is a path in a graph which visits every ...
- PAT甲级——1126 Eulerian Path
我是先在CSDN上发布的这篇文章:https://blog.csdn.net/weixin_44385565/article/details/89155050 1126 Eulerian Path ( ...
- PAT 1126 Eulerian Path
In graph theory, an Eulerian path is a path in a graph which visits every edge exactly once. Similar ...
随机推荐
- express-6 请求和响应对象(1)
URL的组成部分 协议: 协议确定如何传输请求.我们主要是处理http和https.其他常见的协议还有file和ftp. 主机名: 主机名标识服务器.运行在本地计算机(localhost)和本地网络的 ...
- css -- 高度相等的列 -- 3列高度相等
<div class="wrapper"> <div class="box"> <h1>wo shi hao ren< ...
- 个人js类库mycool
// JavaScript Document Sunbye 1.0 //getElementById //function start var $=function(_id){return docum ...
- 每天一个linux命令---mount
查询挂载服务的信息,使用挂载mount命令: [wapmail@app2linux04 monitor]$ mount |grep 172.16.182.146 type nfs (ro,udp,no ...
- 每天一个linux命令--locate
linux下,不知道自己安装的程序放在哪里了,可以使用locate命令进行查找. [hongye@dev107 ~]$ locate activemq.xml /home/hongye/hongyeC ...
- PHP初学[DAY2]
昨天安装了PHP的开发环境,根据一个百度经验里的介绍做的,可惜链接找不着了.目前状况是这样:在Apache24下有一个www的文件夹,通过编辑里边的index.php来学习PHP程序的编写,程序运行的 ...
- A hard puzzle
A hard puzzle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- ccc 使用let
//如果不是恩雅,也不在移动过程中,那么移动 if (!self.hasMoved && !isHold) { var touchLoc = touch.getLocation(); ...
- ccc tiledmap
//移动方向枚举类 var MoveDirection = cc.Enum({ NONE: 0, UP: 1, DOWN: 2, LEFT: 3, RIGHT: 4 }); var minTilesC ...
- Enum(枚举类型)的基本应用
一.前言 在我们日常的开发过程中,我们经常定义使用常量:在Effective Java建议用枚举来替换常量的使用,提高我们代码的质量,总结一下枚举定义常量的基本使用 二.枚举类型说明 1.枚 ...