Skip to content

Commit

Permalink
update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuxiuwei committed Oct 19, 2016
1 parent df02e81 commit 74188fe
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Chapter22_ElementaryGraphAlgorithms.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ in-degree:O(V+E)

### 22.1-6 如果我们用邻接矩阵来存储图,那么绝大多数图算法的运行时间都是Ω(|V|^2)(V为一个图的顶点集),但还是有些例外。比如,给定一个有向图G的邻接矩阵A,我们可以在Ο(|V|)时间内判断图G是否包含一个**通用汇点(universal sink)**,即一个入度为|V|-1出度为0的顶点。请给出这样的算法。
**O(V)思路不好想**:从Matrix[1,1]开始,如果当前位置是0,则往右走一步;如果是1,则往下走一步;一直走到最后一行或者最后一列再停下.再检查该位置是否满足universal sink的定义.
代码见:[Prac22_1_6_UniversalSink.java](https://github.com/zhuxiuwei/CLRS/blob/master/src/chap22_ElementaryGraphAlgo/Prac22_1_5_SquareGraph.java)
代码见:[Prac22_1_6_UniversalSink.java](https://github.com/zhuxiuwei/CLRS/blob/master/src/chap22_ElementaryGraphAlgo/Prac22_1_6_UniversalSink.java)

2 changes: 1 addition & 1 deletion Summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@
本身思路不难,但是在处理最后一个节点的时候(edge case)开始没想好就写,浪费了差不多1小时才都调对。。。。。

#####第22章 基本的图算法
[图通用汇点的O(V)算法](https://github.com/zhuxiuwei/CLRS/blob/master/src/chap22_ElementaryGraphAlgo/Prac22_1_5_SquareGraph.java) ★★
[图通用汇点的O(V)算法](https://github.com/zhuxiuwei/CLRS/blob/master/src/chap22_ElementaryGraphAlgo/Prac22_1_6_UniversalSink.java) ★★
O(V^2)的算法非常简单, 但是**O(V)**算法的思路还是挺有意思的,不好想。[参考](https://github.com/zhuxiuwei/CLRS-1/blob/master/C22-Elementary-Graph-Algorithms/22.1.md)

0 comments on commit 74188fe

Please sign in to comment.