简体   繁体   中英

Calculate max flow of the network

任何人都可以帮助计算这个网络的最大流量并在这个网络图中切割根据我从 s 到 t 的最大流量是 4 而我的老师是 6 !

You would be right; using scipy.sparse.csgraph.maximum_flow :

>>> from scipy.sparse import csr_matrix
>>> from scipy.sparse.csgraph import maximum_flow
>>> m = csr_matrix([[0, 2, 4, 0], [0, 0, 6, 4], [0, 0, 0, 2], [0, 0, 0, 0]])
>>> maximum_flow(m, 0, 3)
MaximumFlowResult with value of 4

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM