27 #ifndef SRC_MAX_FLOW_SRC_PGR_MAXFLOW_HPP_
28 #define SRC_MAX_FLOW_SRC_PGR_MAXFLOW_HPP_
33 #include <boost/graph/push_relabel_max_flow.hpp>
34 #include <boost/graph/edmonds_karp_max_flow.hpp>
35 #include <boost/graph/boykov_kolmogorov_max_flow.hpp>
56 typedef boost::graph_traits<FlowGraph>::vertex_descriptor
V;
57 typedef boost::graph_traits<FlowGraph>::edge_descriptor
E;
58 typedef boost::graph_traits<FlowGraph>::vertex_iterator
V_it;
59 typedef boost::graph_traits<FlowGraph>::edge_iterator
E_it;
60 typedef boost::graph_traits<FlowGraph>::out_edge_iterator
Eout_it;
73 return boost::push_relabel_max_flow(
80 return boost::edmonds_karp_max_flow(
87 size_t num_v = boost::num_vertices(
graph);
88 std::vector<boost::default_color_type> color(num_v);
89 std::vector<int64_t> distance(num_v);
90 return boost::boykov_kolmogorov_max_flow(
96 size_t num_v = boost::num_vertices(
graph);
97 std::vector<boost::default_color_type> color(num_v);
98 std::vector<int64_t> distance(num_v);
99 auto flow = boost::boykov_kolmogorov_max_flow(
107 const std::vector<pgr_edge_t> &
edges,
108 const std::set<int64_t> &source_vertices,
109 const std::set<int64_t> &sink_vertices,
113 const std::vector<pgr_edge_t> &
edges,
114 const std::set<int64_t> &source_vertices,
115 const std::set<int64_t> &sink_vertices,
138 const std::set<int64_t> &source_vertices);
140 const std::set<int64_t> &sink_vertices);
143 const std::vector<pgr_edge_t> &
edges);
145 const std::vector<pgr_edge_t> &
edges);
147 const std::vector<pgr_edge_t> &
edges,
153 std::vector<std::vector<int64_t> > &paths);
158 template <
typename T>
161 const std::set<int64_t> &source_vertices,
162 const std::set<int64_t> &sink_vertices) {
163 std::set<int64_t> vertices(source_vertices);
164 vertices.insert(sink_vertices.begin(), sink_vertices.end());
166 for (
const auto e : edges) {
167 vertices.insert(e.source);
168 vertices.insert(e.target);
171 for (
const auto id : vertices) {
173 id_to_V.insert(std::pair<int64_t, V>(
id, v));
174 V_to_id.insert(std::pair<V, int64_t>(v,
id));
199 #endif // SRC_MAX_FLOW_SRC_PGR_MAXFLOW_HPP_
static edge_t edges[22573]
std::vector< General_path_element_t > edge_disjoint_paths()
void insert_edges_push_relabel(const std::vector< pgr_edge_t > &edges)
std::map< int64_t, V > id_to_V
void add_vertices(const T &edges, const std::set< int64_t > &source_vertices, const std::set< int64_t > &sink_vertices)
boost::graph_traits< FlowGraph >::vertex_iterator V_it
int64_t boykov_kolmogorov()
void flow_dfs(V vertex, int64_t path_id, std::vector< std::vector< int64_t > > &paths)
boost::property_map< FlowGraph, boost::edge_residual_capacity_t >::type residual_capacity
std::map< E, int64_t > E_to_id
boost::adjacency_list< boost::listS, boost::vecS, boost::directedS, boost::property< boost::vertex_index_t, int64_t, boost::property< boost::vertex_color_t, boost::default_color_type, boost::property< boost::vertex_distance_t, int64_t, boost::property< boost::vertex_predecessor_t, Traits::edge_descriptor > > > >, boost::property< boost::edge_capacity_t, int64_t, boost::property< boost::edge_residual_capacity_t, int64_t, boost::property< boost::edge_reverse_t, Traits::edge_descriptor > > > > FlowGraph
boost::graph_traits< FlowGraph >::out_edge_iterator Eout_it
boost::graph_traits< FlowGraph >::edge_iterator E_it
void set_supersource(const std::set< int64_t > &source_vertices)
int64_t get_vertex_id(V v) const
std::vector< pgr_flow_t > get_flow_edges() const
std::vector< General_path_element_t > get_edge_disjoint_paths(int64_t flow)
V get_boost_vertex(int64_t id) const
PgrFlowGraph(const std::vector< pgr_edge_t > &edges, const std::set< int64_t > &source_vertices, const std::set< int64_t > &sink_vertices, int algorithm)
boost::property_map< FlowGraph, boost::edge_reverse_t >::type rev
void set_supersink(const std::set< int64_t > &sink_vertices)
void insert_edges(const std::vector< pgr_edge_t > &edges)
boost::graph_traits< FlowGraph >::edge_descriptor E
boost::property_map< FlowGraph, boost::edge_capacity_t >::type capacity
std::map< V, int64_t > V_to_id
boost::graph_traits< FlowGraph >::vertex_descriptor V
void insert_edges_edge_disjoint(const std::vector< pgr_edge_t > &edges, bool directed)
int64_t get_edge_id(E e) const