Edmond Carps at Boost Graph Library

Part of my algorithm requires computing the maximum flow in a network with entire capacities. I want to use the boost :: edmonds_karp_max_flow algorithm to find the maximum flow.

I tried reading the documentation, but it was very difficult for me, since I had never used BGL before. I created the graph as follows, where the Edge weight attribute should be used as the capacity of the edges in the graph.

 struct Vertex{ int id; bool flag; }; struct Edge{ int weight; }; typedef boost::adjacency_list< boost::listS, boost::vecS, boost::undirectedS, Vertex, Edge >MyGraph; 

My goal is to write the following function

  int max_flow( const MyGraph& gr, int u, int v) { // compute the maximum flow between vertices with ids u,v } 

can someone show me an example of how to implement this function?

+4
source share

Source: https://habr.com/ru/post/1396823/


All Articles