其他分享
首页 > 其他分享> > 数据结构10 Network Flow Problems

数据结构10 Network Flow Problems

作者:互联网

问题描述:在一个有向图中,给定源点和目标点,给定每一条边能通过的流量,求通过源点最大的流量。

解法:

Gf:流量图,Gr:余量图

初始时Gf为空,Gr和G相同。

1.选择路径:在图Gr任意选择一条源点到目标点的路径,

2.更新Gf:在Gf中添加该路径,路径的流量由最小流量确定

3.更新Gr:如果路径中的一部分为为a->b,整条路径的最小流量为q,a->b本身的流量为p,则Gr中添加b->a,流量为q,a->b流量更新为p-q(如果为0就删去a->b)

4.重复1,2,3直到Gr中找不到路径为止

最小生成树

对于一个带权联通图,可以生成一颗树,使得边权值最小,称为最小生成树

Prim’s Algorithm :

1.任意选择一个点

2.选择与这个点相连的权值最小的边和点加入到生成树

3.对于已经生成的部分,再次重复2(即与生成的部分相连的边中权值最小的加入生成树)

4.当所有的点加入,则停止。

Kruskal’s Algorithm 

1.选择权值最小的边和与他相连的点加入生成树。

2.从原图中删去这条边

3.选取权值最小的且不构成Circle的边和点加入到生成树(不要求和已经生成的部分相连)

4.从原图中删去这条边

5.重复3,4直到包含所有的点。

 题目

 1.To find the minimum spanning tree with Kruskal's algorithm for the following graph. Which edge will be added in the final step?

图1.jpg

A.(v1,v4)

B.(v1,v2)

C.(v4,v6)

D.uncertain

总是选择不能构成环的最小权值边加入,2-3,3-5,3-4,5-6,4-6,2-1 B

2.The minimum spanning tree of any weighted graph __D__

A.must be unique

B.must not be unique

C.exists but may not be unique

D.may not exist

因为没有说是联通的图(我发现cy很喜欢出这种题),如果联通的话,也不是唯一的,假如权值相同的矩形的最小生成树就有两种

3.The maximum flow in the network of the given Figure is:

 

A.104

B.123

C.120

D.97

老老实实按照算法去画。

4.When solving the maximum flow problem for graph G, if partial states of the G​f​​ ( will be the maximum flow when the algorithm terminates) and G​r​​ (residual graph) are shown as the following, what must be the capacity of (v1, v2) or of (v2,v1) in the original graph G?

图2.jpg

A.the capacity of (v1, v2) is 2

B.the capacity of (v1, v2) is 3

C.the capacity of (v1, v2) is 5

D.the capacity of (v2, v1) is 5

在Gf中添加路径,在Gr中反向添加,因此添加了一个1-2的路径,反向添加了2-3的路径,但是最小流量是3,Gr中的总流量是不变的,是5 C

 

 

 

标签:10,Network,路径,Flow,最小,生成,v1,v2,Gr
来源: https://blog.csdn.net/HGGshiwo/article/details/112425734