INF421 Quiz 6 整理

Q1:

If G is a tree, then the distances from a vertex s to all other vertices can be computed easily in time O(m) (where m is the number of edges).

Sol:
True
因为树没有Cycle,所以只要遍历到了就可以。
我们可以对s用BFS,并对于没有遍历到的顶点,我们用已经遍历到的节点u来更新它的距离:用d(s,v) = d(s,u) + w(u,v).

Q2:

If there is a unique edge with minimal weight, then this is part of any shortest path tree encoding the shortest paths from s to any other vertex.

Sol:
False
注意!这题问的是存储s到其他顶点最短路径的树
反例:

10
5
10
S
B
C

Q3:

The diameter of a connected graph G is the smallest number d such that any two vertices are connected by a path of at most d edges. In the Bellman-Ford algorithm, it suffices to take the outer loop from 1 to d.

Sol:
False.
经过d条边的路径并不一定最小,例如[10,10…,10],它比经过多于d条但每条边距离为1的路径要长!

Q4:

一张图中如果只有2个顶点度数为奇数,其余度数都是偶数。则这张图存在Eulerian Cycle。
If all vertices of a graph except exactly two have even degree, then an Eulerian path exists, that is, a (not necessarily simple) path that uses each edge exactly once.

Sol:
True
我们可以现将两个顶点度数为奇数的点连起来,这样就存在Eulerian Cycle(每边能遍历一次),我们不走加的那条边即可得到原图的Eulerian Cycle。

Q5:

Max-Cut problem : Given an undirected graph G=(V,E), partition the vertex set into two classes V=X∪Y such that the number of “cut edges” is maximized,
Problem : Find a 0.5 approximation algorithm !

Minimum Cut:
在这里插入图片描述
Maximum Cut:
在这里插入图片描述

所以我们的边有三类:

  • 属于类1内部
  • 属于类2内部
  • 用于连接1和2 (每次切割的两端都分别属于1和2)

鉴于边的总数量有限,我们的目的是得到一个切法使得类1和类2内部边数之和最少。

Sol

猜你喜欢

转载自blog.csdn.net/weixin_44495738/article/details/112494610