Commit 4d212c1b authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Switch from boost::adjacency_list<> to custom made and lightweight adj_list<>

Dumping boost::adjacency_list<> improves memory usage by a factor of
two, and also slightly improves performance in some cases.
parent 5b67db19
...@@ -255,17 +255,17 @@ G2_loop_k: ++G2_verts.first; ...@@ -255,17 +255,17 @@ G2_loop_k: ++G2_verts.first;
{ {
vertex1_t vk = dfs_vertices[dfs_num_k]; vertex1_t vk = dfs_vertices[dfs_num_k];
num_edges_on_k -= num_edges_on_k -=
count_if(adjacent_vertices(f[vk], G2), make_indirect_pmap(in_S)); count_if(adjacent_vertices(vertex(f[vk], G2), G2), make_indirect_pmap(in_S));
for (int jj = 0; jj < dfs_num_k; ++jj) { for (int jj = 0; jj < dfs_num_k; ++jj) {
vertex1_t j = dfs_vertices[jj]; vertex1_t j = dfs_vertices[jj];
num_edges_on_k -= count(adjacent_vertices(f[j], G2), f[vk]); num_edges_on_k -= count(adjacent_vertices(vertex(f[j], G2), G2), f[vk]);
} }
} }
if (num_edges_on_k != 0) if (num_edges_on_k != 0)
goto return_point_false; goto return_point_false;
fi_adj = adjacent_vertices(f[i], G2); fi_adj = adjacent_vertices(vertex(f[i], G2), G2);
while (fi_adj.first != fi_adj.second) { while (fi_adj.first != fi_adj.second) {
{ {
vertex2_t v = *fi_adj.first; vertex2_t v = *fi_adj.first;
...@@ -290,7 +290,7 @@ fi_adj_loop_k:++fi_adj.first; ...@@ -290,7 +290,7 @@ fi_adj_loop_k:++fi_adj.first;
} }
} }
else { else {
if (container_contains(adjacent_vertices(f[i], G2), f[j])) { if (container_contains(adjacent_vertices(vertex(f[i], G2), G2), f[j])) {
++num_edges_on_k; ++num_edges_on_k;
match_continuation new_k; match_continuation new_k;
new_k.position = match_continuation::pos_dfs_num; new_k.position = match_continuation::pos_dfs_num;
......
...@@ -134,10 +134,7 @@ void get_motifs(GraphInterface& g, size_t k, python::list subgraph_list, ...@@ -134,10 +134,7 @@ void get_motifs(GraphInterface& g, size_t k, python::list subgraph_list,
(sub, boost::bind<void>(retrieve_from_list(), _1, (sub, boost::bind<void>(retrieve_from_list(), _1,
boost::ref(list), boost::ref(done)))(); boost::ref(list), boost::ref(done)))();
if (!done) if (!done)
{
sub.ReIndexEdges();
subgraph_list.append(sub); subgraph_list.append(sub);
}
} }
subgraph_list.reverse(); subgraph_list.reverse();
} }
......
...@@ -252,8 +252,8 @@ bool graph_cmp(Graph& g1, Graph& g2) ...@@ -252,8 +252,8 @@ bool graph_cmp(Graph& g1, Graph& g2)
} }
// short hand for both types of subgraphs // short hand for both types of subgraphs
typedef adjacency_list<vecS,vecS,bidirectionalS> d_graph_t; typedef adj_list<size_t> d_graph_t;
typedef adjacency_list<vecS,vecS,undirectedS> u_graph_t; typedef adj_list<size_t> u_graph_t;
// we need this wrap to use the UndirectedAdaptor only on directed graphs // we need this wrap to use the UndirectedAdaptor only on directed graphs
struct wrap_undirected struct wrap_undirected
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "graph_blockmodel.hh" #include "graph_blockmodel.hh"
using namespace boost; using namespace boost;
using namespace graph_tool;
// ==================== // ====================
// Entropy calculation // Entropy calculation
...@@ -131,8 +132,7 @@ python::object do_min_dist(GraphInterface& gi, int n, boost::any omrs, ...@@ -131,8 +132,7 @@ python::object do_min_dist(GraphInterface& gi, int n, boost::any omrs,
void do_b_join(GraphInterface& gi, size_t r, size_t s, boost::any omrs, void do_b_join(GraphInterface& gi, size_t r, size_t s, boost::any omrs,
boost::any omrp, boost::any omrm, boost::any owr, bool deg_corr, boost::any omrp, boost::any omrm, boost::any owr)
vector<int>& vlist)
{ {
typedef property_map_type::apply<int32_t, typedef property_map_type::apply<int32_t,
GraphInterface::vertex_index_map_t>::type GraphInterface::vertex_index_map_t>::type
...@@ -149,8 +149,7 @@ void do_b_join(GraphInterface& gi, size_t r, size_t s, boost::any omrs, ...@@ -149,8 +149,7 @@ void do_b_join(GraphInterface& gi, size_t r, size_t s, boost::any omrs,
vmap_t wr = any_cast<vmap_t>(owr); vmap_t wr = any_cast<vmap_t>(owr);
run_action<graph_tool::detail::all_graph_views, mpl::true_>() run_action<graph_tool::detail::all_graph_views, mpl::true_>()
(gi, boost::bind<void>(b_join(r, s), mrs, mrp, mrm, wr, deg_corr, (gi, boost::bind<void>(b_join(r, s), mrs, mrp, mrm, wr, _1))();
ref(vlist), _1))();
} }
// =============================== // ===============================
...@@ -377,9 +376,8 @@ struct move_sweep_dispatch ...@@ -377,9 +376,8 @@ struct move_sweep_dispatch
: eweight(eweight), vweight(vweight), oegroups(egroups), esrcpos(esrcpos), : eweight(eweight), vweight(vweight), oegroups(egroups), esrcpos(esrcpos),
etgtpos(etgtpos), label(label), L(L), vlist(vlist), etgtpos(etgtpos), label(label), L(L), vlist(vlist),
deg_corr(deg_corr), beta(beta), verbose(verbose), deg_corr(deg_corr), beta(beta), sequential(sequential), verbose(verbose),
max_edge_index(max_edge_index), max_edge_index(max_edge_index), rng(rng), S(S), nmoves(nmoves), bgi(bgi)
rng(rng), S(S), nmoves(nmoves), bgi(bgi)
{} {}
Eprop eweight; Eprop eweight;
...@@ -421,7 +419,6 @@ struct move_sweep_dispatch ...@@ -421,7 +419,6 @@ struct move_sweep_dispatch
void dispatch(Eprop mrs, Vprop mrp, Vprop mrm, Vprop wr, Vprop b, Graph& g, void dispatch(Eprop mrs, Vprop mrp, Vprop mrm, Vprop wr, Vprop b, Graph& g,
boost::any& aemat, BGraph& bg) const boost::any& aemat, BGraph& bg) const
{ {
const GraphWrap<BGraph> wbg(bg, bgi);
typedef typename get_emat_t::apply<BGraph>::type emat_t; typedef typename get_emat_t::apply<BGraph>::type emat_t;
emat_t& emat = any_cast<emat_t&>(aemat); emat_t& emat = any_cast<emat_t&>(aemat);
...@@ -444,7 +441,7 @@ struct move_sweep_dispatch ...@@ -444,7 +441,7 @@ struct move_sweep_dispatch
egroups.get_unchecked(num_vertices(bg)), egroups.get_unchecked(num_vertices(bg)),
esrcpos.get_unchecked(max_edge_index + 1), esrcpos.get_unchecked(max_edge_index + 1),
etgtpos.get_unchecked(max_edge_index + 1), etgtpos.get_unchecked(max_edge_index + 1),
g, wbg, emat, sequential, verbose, rng, S, nmoves); g, bg, emat, sequential, verbose, rng, S, nmoves);
} }
}; };
...@@ -525,8 +522,7 @@ struct collect_edge_marginals_dispatch ...@@ -525,8 +522,7 @@ struct collect_edge_marginals_dispatch
void operator()(Graph& g, size_t B, Vprop cb, MEprop p, void operator()(Graph& g, size_t B, Vprop cb, MEprop p,
tr1::tuple<boost::any, GraphInterface&> abg) const tr1::tuple<boost::any, GraphInterface&> abg) const
{ {
typedef typename Graph::orig_graph_t graph_t; Graph& bg = *any_cast<Graph*>(get<0>(abg));
const GraphWrap<graph_t> bg(*any_cast<graph_t*>(get<0>(abg)), get<1>(abg));
collect_edge_marginals(B, cb.get_unchecked(num_vertices(bg)), p, g, bg); collect_edge_marginals(B, cb.get_unchecked(num_vertices(bg)), p, g, bg);
} }
}; };
......
...@@ -26,6 +26,7 @@ using __gnu_cxx::power; ...@@ -26,6 +26,7 @@ using __gnu_cxx::power;
#include "tr1_include.hh" #include "tr1_include.hh"
#include TR1_HEADER(unordered_set) #include TR1_HEADER(unordered_set)
#include TR1_HEADER(unordered_map)
#include TR1_HEADER(tuple) #include TR1_HEADER(tuple)
#include <dense_hash_set> #include <dense_hash_set>
...@@ -95,7 +96,7 @@ inline double eterm(const Edge& e, const Eprop& mrs, const Graph& g) ...@@ -95,7 +96,7 @@ inline double eterm(const Edge& e, const Eprop& mrs, const Graph& g)
// "vertex" term of the entropy // "vertex" term of the entropy
template <class Graph, class Vertex, class Vprop> template <class Graph, class Vertex, class Vprop>
inline double vterm(Vertex v, Vprop& mrp, Vprop& mrm, Vprop& wr, bool deg_corr, inline double vterm(Vertex v, Vprop& mrp, Vprop& mrm, Vprop& wr, bool deg_corr,
Graph& g) Graph&)
{ {
double one = 0.5; double one = 0.5;
...@@ -132,9 +133,9 @@ struct entropy ...@@ -132,9 +133,9 @@ struct entropy
// obtain the "super block" which is a merger of two blocks // obtain the "super block" which is a merger of two blocks
template <class Graph, class Vertex, class Eprop, class Vprop> template <class Graph, class Vertex, class Eprop, class Vprop>
void super_block(Vertex u, Vertex v, Eprop mrs, Vprop mrp, Vprop mrm, Vprop wr, void super_block(Vertex u, Vertex v, Eprop mrs, Vprop mrp, Vprop mrm, Vprop wr,
bool deg_corr, Graph& g, unordered_set<Vertex>& nsp, Graph& g, tr1::unordered_set<Vertex>& nsp,
unordered_set<Vertex>& nsm, unordered_map<Vertex, size_t>& msp, tr1::unordered_set<Vertex>& nsm, tr1::unordered_map<Vertex, size_t>& msp,
unordered_map<Vertex, size_t>& msm, size_t& ml, size_t& m_rp, tr1::unordered_map<Vertex, size_t>& msm, size_t& ml, size_t& m_rp,
size_t& m_rm, size_t& w_r) size_t& m_rm, size_t& w_r)
{ {
ml = 0; ml = 0;
...@@ -216,12 +217,12 @@ struct dist ...@@ -216,12 +217,12 @@ struct dist
d += eterm(*e, mrs, g); d += eterm(*e, mrs, g);
} }
unordered_set<Vertex> nsp, nsm; tr1::unordered_set<Vertex> nsp, nsm;
unordered_map<Vertex, size_t> msp, msm; tr1::unordered_map<Vertex, size_t> msp, msm;
size_t ml, m_rp, m_rm, w_r; size_t ml, m_rp, m_rm, w_r;
super_block(r, s, mrs, mrp, mrm, wr, deg_corr, g, nsp, nsm, msp, msm, super_block(r, s, mrs, mrp, mrm, wr, g, nsp, nsm, msp, msm, ml, m_rp,
ml, m_rp, m_rm, w_r); m_rm, w_r);
if (!is_directed::apply<Graph>::type::value) if (!is_directed::apply<Graph>::type::value)
{ {
...@@ -349,19 +350,18 @@ struct b_join ...@@ -349,19 +350,18 @@ struct b_join
size_t rr, ss; size_t rr, ss;
template <class Graph, class Eprop, class Vprop> template <class Graph, class Eprop, class Vprop>
void operator()(Eprop mrs, Vprop mrp, Vprop mrm, Vprop wr, bool deg_corr, void operator()(Eprop mrs, Vprop mrp, Vprop mrm, Vprop wr, Graph& g) const
vector<int>& vlist, Graph& g) const
{ {
typedef typename graph_traits<Graph>::vertex_descriptor vertex_t; typedef typename graph_traits<Graph>::vertex_descriptor vertex_t;
unordered_set<vertex_t> nsp, nsm; tr1::unordered_set<vertex_t> nsp, nsm;
unordered_map<vertex_t, size_t> msp, msm; tr1::unordered_map<vertex_t, size_t> msp, msm;
size_t ml, m_rp, m_rm, w_r; size_t ml, m_rp, m_rm, w_r;
vertex_t r = vertex(rr, g); vertex_t r = vertex(rr, g);
vertex_t s = vertex(ss, g); vertex_t s = vertex(ss, g);
super_block(r, s, mrs, mrp, mrm, wr, deg_corr, g, nsp, nsm, msp, msm, super_block(r, s, mrs, mrp, mrm, wr, g, nsp, nsm, msp, msm, ml, m_rp,
ml, m_rp, m_rm, w_r); m_rm, w_r);
mrp[r] = m_rp; mrp[r] = m_rp;
mrm[r] = m_rm; mrm[r] = m_rm;
...@@ -612,7 +612,7 @@ inline void insert_m_entry(Vertex r, Vertex s, MEntry& m_entries, ...@@ -612,7 +612,7 @@ inline void insert_m_entry(Vertex r, Vertex s, MEntry& m_entries,
// after the move // after the move
template <class Graph, class BGraph, class Vertex, class Vprop, class MEntry, template <class Graph, class BGraph, class Vertex, class Vprop, class MEntry,
class MEntrySet> class MEntrySet>
void move_entries(Vertex v, Vertex nr, Vprop& b, Graph& g, BGraph& bg, void move_entries(Vertex v, Vertex nr, Vprop& b, Graph& g, BGraph&,
MEntry& m_entries, MEntrySet& m_entries_set) MEntry& m_entries, MEntrySet& m_entries_set)
{ {
typedef typename graph_traits<Graph>::vertex_descriptor vertex_t; typedef typename graph_traits<Graph>::vertex_descriptor vertex_t;
...@@ -982,7 +982,7 @@ struct build_egroups ...@@ -982,7 +982,7 @@ struct build_egroups
// Sampling marginal probabilities on the edges // Sampling marginal probabilities on the edges
template <class Graph, class Vprop, class MEprop> template <class Graph, class Vprop, class MEprop>
void collect_edge_marginals(size_t B, Vprop b, MEprop p, Graph& g, Graph& bg) void collect_edge_marginals(size_t B, Vprop b, MEprop p, Graph& g, Graph&)
{ {
typedef typename graph_traits<Graph>::vertex_descriptor vertex_t; typedef typename graph_traits<Graph>::vertex_descriptor vertex_t;
......
...@@ -131,7 +131,4 @@ void community_network(GraphInterface& gi, GraphInterface& cgi, ...@@ -131,7 +131,4 @@ void community_network(GraphInterface& gi, GraphInterface& cgi,
_3, edge_count), _3, edge_count),
writable_vertex_properties(), eweight_properties()) writable_vertex_properties(), eweight_properties())
(community_property, eweight); (community_property, eweight);
cgi.ReIndexEdges();
} }
...@@ -100,7 +100,7 @@ struct get_community_network_edges ...@@ -100,7 +100,7 @@ struct get_community_network_edges
template <class Graph, class CommunityGraph, class CommunityMap, template <class Graph, class CommunityGraph, class CommunityMap,
class CCommunityMap, class EdgeWeightMap, class CCommunityMap, class EdgeWeightMap,
class EdgeIndex, class EdgeProperty> class EdgeIndex, class EdgeProperty>
void operator()(const Graph& g, CommunityGraph& cg, EdgeIndex cedge_index, void operator()(const Graph& g, CommunityGraph& cg, EdgeIndex,
CommunityMap s_map, CCommunityMap cs_map, CommunityMap s_map, CCommunityMap cs_map,
EdgeWeightMap eweight, EdgeProperty edge_count, EdgeWeightMap eweight, EdgeProperty edge_count,
bool self_loops) const bool self_loops) const
...@@ -140,7 +140,6 @@ struct get_community_network_edges ...@@ -140,7 +140,6 @@ struct get_community_network_edges
{ {
ce = add_edge(cs, ct, cg).first; ce = add_edge(cs, ct, cg).first;
comm_edges[make_pair(cs, ct)] = ce; comm_edges[make_pair(cs, ct)] = ce;
put(cedge_index, ce, comm_edges.size() - 1);
} }
put(edge_count, ce, get(edge_count, ce) + get(eweight, *e)); put(edge_count, ce, get(edge_count, ce) + get(eweight, *e));
} }
......
...@@ -1043,7 +1043,7 @@ private: ...@@ -1043,7 +1043,7 @@ private:
}; };
template <class Graph, class VertexIterator, class PosMap> template <class Graph, class VertexIterator, class PosMap>
void draw_vertices(Graph& g, pair<VertexIterator,VertexIterator> v_range, void draw_vertices(Graph&, pair<VertexIterator,VertexIterator> v_range,
PosMap pos_map, attrs_t& attrs, attrs_t& defaults, PosMap pos_map, attrs_t& attrs, attrs_t& defaults,
Cairo::Context& cr) Cairo::Context& cr)
{ {
...@@ -1150,8 +1150,8 @@ struct do_cairo_draw_vertices ...@@ -1150,8 +1150,8 @@ struct do_cairo_draw_vertices
{ {
template <class Graph, class PosMap, class VertexOrder> template <class Graph, class PosMap, class VertexOrder>
void operator()(Graph& g, PosMap pos, VertexOrder vertex_order, void operator()(Graph& g, PosMap pos, VertexOrder vertex_order,
attrs_t& vattrs, attrs_t& eattrs, attrs_t& vdefaults, attrs_t& vattrs, attrs_t&, attrs_t& vdefaults,
attrs_t& edefaults, Cairo::Context& cr) const attrs_t&, Cairo::Context& cr) const
{ {
ordered_range<typename graph_traits<Graph>::vertex_iterator> ordered_range<typename graph_traits<Graph>::vertex_iterator>
vertex_range(vertices(g)); vertex_range(vertices(g));
...@@ -1233,7 +1233,7 @@ void populate_defaults(python::dict odefaults, attrs_t& defaults) ...@@ -1233,7 +1233,7 @@ void populate_defaults(python::dict odefaults, attrs_t& defaults)
struct populate_edge_attrs struct populate_edge_attrs
{ {
template <class Graph> template <class Graph>
void operator()(Graph& g, python::dict oeattrs, attrs_t& eattrs, void operator()(Graph&, python::dict oeattrs, attrs_t& eattrs,
python::dict oedefaults, attrs_t& edefaults) const python::dict oedefaults, attrs_t& edefaults) const
{ {
typedef typename graph_traits<Graph>::edge_descriptor edge_t; typedef typename graph_traits<Graph>::edge_descriptor edge_t;
......
...@@ -210,6 +210,36 @@ make_unchecked_vector_property_map(IndexMap index) ...@@ -210,6 +210,36 @@ make_unchecked_vector_property_map(IndexMap index)
return unchecked_vector_property_map<T, IndexMap>(index); return unchecked_vector_property_map<T, IndexMap>(index);
} }
template <class Type, class Index>
unchecked_vector_property_map<Type, Index>
get_unchecked(checked_vector_property_map<Type, Index> prop)
{
return prop.get_unchecked();
}
template <class Prop>
Prop
get_unchecked(Prop prop)
{
return prop;
}
template <class Type, class Index>
checked_vector_property_map<Type, Index>
get_checked(unchecked_vector_property_map<Type, Index> prop)
{
return prop.get_checked();
}
template <class Prop>
Prop
get_checked(Prop prop)
{
return prop;
}
} }
#endif #endif
...@@ -97,21 +97,6 @@ void deaugment_graph(Graph& g, AugmentedMap augmented) ...@@ -97,21 +97,6 @@ void deaugment_graph(Graph& g, AugmentedMap augmented)
} }
} }
template <class Type, class Index>
unchecked_vector_property_map<Type, Index>
get_unchecked(checked_vector_property_map<Type, Index> prop)
{
return prop.get_unchecked();
}
template <class Prop>
Prop
get_unchecked(Prop prop)
{
return prop;
}
} // graph_tool namespace } // graph_tool namespace
#endif // GRAPH_AUGMENT_HH #endif // GRAPH_AUGMENT_HH
...@@ -47,15 +47,20 @@ struct get_edmonds_karp_max_flow ...@@ -47,15 +47,20 @@ struct get_edmonds_karp_max_flow
unchecked_vector_property_map<edge_t,VertexIndex> unchecked_vector_property_map<edge_t,VertexIndex>
pred(vertex_index, num_vertices(g)); pred(vertex_index, num_vertices(g));
augment_graph(g, augmented.get_checked(), cm, reverse_map.get_checked(), typedef typename remove_const<Graph>::type GT;
res); GT& u = const_cast<GT&>(g);
augment_graph(u,
augmented.get_checked(),
get_checked(cm),
reverse_map.get_checked(),
get_checked(res));
boost::edmonds_karp_max_flow(g._g, vertex(src, g), vertex(sink, g), boost::edmonds_karp_max_flow(g, vertex(src, g), vertex(sink, g),
get_unchecked(cm), get_unchecked(cm),
res.get_unchecked(), get_unchecked(res),
reverse_map, color, pred); reverse_map, color, pred);
deaugment_graph(g, augmented.get_checked()); deaugment_graph(u, augmented.get_checked());
} }
}; };
...@@ -63,11 +68,11 @@ struct get_edmonds_karp_max_flow ...@@ -63,11 +68,11 @@ struct get_edmonds_karp_max_flow
void edmonds_karp_max_flow(GraphInterface& gi, size_t src, size_t sink, void edmonds_karp_max_flow(GraphInterface& gi, size_t src, size_t sink,
boost::any capacity, boost::any res) boost::any capacity, boost::any res)
{ {
run_action<graph_tool::detail::always_directed, mpl::true_>() run_action<graph_tool::detail::always_directed>()
(gi, bind<void>(get_edmonds_karp_max_flow(), (gi, bind<void>(get_edmonds_karp_max_flow(),
_1, gi.GetVertexIndex(), gi.GetEdgeIndex(), _1, gi.GetVertexIndex(), gi.GetEdgeIndex(),
gi.GetMaxEdgeIndex(), gi.GetMaxEdgeIndex(),
src, sink, _2, _3), src, sink, _2, _3),
edge_scalar_properties(), writable_edge_scalar_properties()) writable_edge_scalar_properties(), writable_edge_scalar_properties())
(capacity,res); (capacity,res);
} }
...@@ -61,7 +61,7 @@ struct get_kolmogorov_max_flow ...@@ -61,7 +61,7 @@ struct get_kolmogorov_max_flow
{ {
template <class Graph, class EdgeIndex, class VertexIndex, template <class Graph, class EdgeIndex, class VertexIndex,
class CapacityMap, class ResidualMap> class CapacityMap, class ResidualMap>
void operator()(Graph& g, EdgeIndex edge_index, size_t max_e, void operator()(Graph& g, EdgeIndex edge_index, size_t,
VertexIndex vertex_index, size_t src, size_t sink, VertexIndex vertex_index, size_t src, size_t sink,
CapacityMap cm, ResidualMap res) const CapacityMap cm, ResidualMap res) const
{ {
...@@ -77,13 +77,16 @@ struct get_kolmogorov_max_flow ...@@ -77,13 +77,16 @@ struct get_kolmogorov_max_flow
unchecked_vector_property_map<size_t,VertexIndex> unchecked_vector_property_map<size_t,VertexIndex>
dist_map(vertex_index, num_vertices(g)); dist_map(vertex_index, num_vertices(g));
augment_graph(g, augmented, cm, reverse_map, res, true); typedef typename remove_const<Graph>::type GT;
GT& u = const_cast<GT&>(g);
KOLMOGOROV_MAX_FLOW(g._g, cm, res, reverse_map, pred_map, color_map, augment_graph(u, augmented, cm, reverse_map, res, true);
KOLMOGOROV_MAX_FLOW(g, cm, res, reverse_map, pred_map, color_map,
dist_map, vertex_index, vertex(src, g), dist_map, vertex_index, vertex(src, g),
vertex(sink, g)); vertex(sink, g));
deaugment_graph(g, augmented); deaugment_graph(u, augmented);
} }
}; };
...@@ -96,6 +99,6 @@ void kolmogorov_max_flow(GraphInterface& gi, size_t src, size_t sink, ...@@ -96,6 +99,6 @@ void kolmogorov_max_flow(GraphInterface& gi, size_t src, size_t sink,
(gi, bind<void>(get_kolmogorov_max_flow(), (gi, bind<void>(get_kolmogorov_max_flow(),
_1, gi.GetEdgeIndex(), gi.GetMaxEdgeIndex(), _1, gi.GetEdgeIndex(), gi.GetMaxEdgeIndex(),
gi.GetVertexIndex(), src, sink, _2, _3), gi.GetVertexIndex(), src, sink, _2, _3),
edge_scalar_properties(), writable_edge_scalar_properties()) writable_edge_scalar_properties(), writable_edge_scalar_properties())
(capacity,res); (capacity,res);
} }
...@@ -67,14 +67,17 @@ struct get_push_relabel_max_flow ...@@ -67,14 +67,17 @@ struct get_push_relabel_max_flow
unchecked_vector_property_map<edge_t,EdgeIndex> unchecked_vector_property_map<edge_t,EdgeIndex>
reverse_map(edge_index, max_e); reverse_map(edge_index, max_e);
augment_graph(g, augmented, cm, typedef typename remove_const<Graph>::type GT;
GT& u = const_cast<GT&>(g);
augment_graph(u, augmented, cm,
reverse_map.get_checked(), res); reverse_map.get_checked(), res);
boost::push_relabel_max_flow(g._g, vertex(src, g), vertex(sink, g), boost::push_relabel_max_flow(g, vertex(src, g), vertex(sink, g),
get_unchecked(cm), get_unchecked(cm),