gpt4 book ai didi

algorithm - Ford-Fulkerson在具体问题中如何实现?

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:07:19 24 4
gpt4 key购买 nike

<分区>

我正在做一个特定的练习,但我卡住了。

解决:

Solve the circulation demand problem. There are some factories that produce goods and some villages where the goods have to be delivered. They are connected by a networks of roads with each road having a capacity for the maximum amount of goods that can flow through it. The problem is to find if there is a circulation that satisfies the demand. This problem can be transformed into a maximum-flow problem. Assume that every factory node fi has a production rate pi. In addition, that di is the demand rate of village vi. Your input will be the graph given using an adjacency list for each node of it. Initially give a number describing the number of nodes of the graph and then one line for the adjacency list of each node (together with the capacities) e.g. “d a 10 c 5” means that node d is connected to a (with capacity 10) and to c (with capacity 5). Finally give the production rates for each node (where there are factories) and after that the demand rates for the villages again on each node.

据我所知,我需要这样的输入文件:

10
a b 10 c 20
b c 5 d 10
d e 7 f 8
a 10
e -5

//nodes = 10
//directed graph -> a to b with capacity 10, a to c with capacity 20
//a production = 10, e consumption = -5

我已经得出结论,我应该使用 Ford-Fulkerson 算法来找到最大流量(因为这是输出所要求的)

查看算法的不同实现(我正在考虑使用 C 或 Java 对其进行编码),我偶然发现了以下问题:

Ford-Fulkerson 仅适用于 1 个源和 1 个汇。在这个问题中,我们有测试用例,例如有 3 个工厂和 2 个村庄。有人可以启发我,因为我真的被卡住了。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com