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

Fix compilation issues with Boost 1.51

parent 8961b6ce
......@@ -20,6 +20,7 @@
#include "graph.hh"
#include "graph_selectors.hh"
#include "graph_properties.hh"
#include "graph_util.hh"
#include "graph_motifs.hh"
......@@ -29,11 +30,6 @@ using namespace std;
using namespace boost;
using namespace graph_tool;
struct null_copy
{
template <class T1, class T2>
void operator()(const T1&, const T2&) const {}
};
struct append_to_list
{
......@@ -46,8 +42,7 @@ struct append_to_list
u_graph_t>::type graph_t;
vector<graph_t>& glist = any_cast<vector<graph_t>&>(list);
glist.push_back(graph_t());
copy_graph(g, glist.back(), vertex_copy(null_copy()).
edge_copy(null_copy()));
graph_copy(g, glist.back());
}
};
......@@ -65,8 +60,7 @@ struct retrieve_from_list
done = true;
return;
}
copy_graph(glist.back(), g, edge_copy(null_copy()));
glist.pop_back();
graph_copy(glist.back(), g);
}
};
......
......@@ -18,11 +18,6 @@
#ifndef GRAPH_MOTIFS_HH
#define GRAPH_MOTIFS_HH
#if (BOOST_VERSION / 100 % 1000 >= 49)
#include <boost/graph/copy_alt.hpp>
#else
#include <boost/graph/copy.hpp>
#endif
#include <boost/graph/isomorphism.hpp>
#if (GCC_VERSION >= 40400)
# include <tr1/unordered_set>
......
......@@ -31,24 +31,29 @@ using namespace boost;
struct get_edmonds_karp_max_flow
{
template <class Graph, class EdgeIndex, class CapacityMap,
template <class Graph, class VertexIndex, class EdgeIndex, class CapacityMap,
class ResidualMap>
void operator()(Graph& g, EdgeIndex edge_index, size_t max_e, size_t src,
size_t sink, CapacityMap cm, ResidualMap res) const
void operator()(Graph& g, VertexIndex vertex_index, EdgeIndex edge_index,
size_t max_e, size_t src, size_t sink, CapacityMap cm,
ResidualMap res) const
{
typedef typename graph_traits<Graph>::edge_descriptor edge_t;
unchecked_vector_property_map<bool,EdgeIndex>
augmented(edge_index, max_e);
unchecked_vector_property_map<edge_t,EdgeIndex>
reverse_map(edge_index, max_e);
unchecked_vector_property_map<default_color_type,VertexIndex>
color(vertex_index, num_vertices(g));
unchecked_vector_property_map<edge_t,VertexIndex>
pred(vertex_index, num_vertices(g));
augment_graph(g, augmented.get_checked(), cm, reverse_map.get_checked(),
res);
boost::edmonds_karp_max_flow(g._g, vertex(src, g), vertex(sink, g),
capacity_map(get_unchecked(cm)).
reverse_edge_map(reverse_map).
residual_capacity_map(res.get_unchecked()));
get_unchecked(cm),
res.get_unchecked(),
reverse_map, color, pred);
deaugment_graph(g, augmented.get_checked());
}
......@@ -60,7 +65,8 @@ void edmonds_karp_max_flow(GraphInterface& gi, size_t src, size_t sink,
{
run_action<graph_tool::detail::always_directed, mpl::true_>()
(gi, bind<void>(get_edmonds_karp_max_flow(),
_1, gi.GetEdgeIndex(), gi.GetMaxEdgeIndex(),
_1, gi.GetVertexIndex(), gi.GetEdgeIndex(),
gi.GetMaxEdgeIndex(),
src, sink, _2, _3),
edge_scalar_properties(), writable_edge_scalar_properties())
(capacity,res);
......
......@@ -55,10 +55,11 @@ using namespace boost;
struct get_push_relabel_max_flow
{
template <class Graph, class EdgeIndex, class CapacityMap,
template <class Graph, class VertexIndex, class EdgeIndex, class CapacityMap,
class ResidualMap>
void operator()(Graph& g, EdgeIndex edge_index, size_t max_e, size_t src,
size_t sink, CapacityMap cm, ResidualMap res) const
void operator()(Graph& g, VertexIndex vertex_index, EdgeIndex edge_index,
size_t max_e, size_t src, size_t sink, CapacityMap cm,
ResidualMap res) const
{
typedef typename graph_traits<Graph>::edge_descriptor edge_t;
checked_vector_property_map<bool,EdgeIndex>
......@@ -70,10 +71,9 @@ struct get_push_relabel_max_flow
reverse_map.get_checked(), res);
boost::push_relabel_max_flow(g._g, vertex(src, g), vertex(sink, g),
capacity_map(get_unchecked(cm)).
reverse_edge_map(reverse_map).
residual_capacity_map(res.get_unchecked()));
get_unchecked(cm),
res.get_unchecked(),
reverse_map, vertex_index);
deaugment_graph(g, augmented);
}
};
......@@ -84,7 +84,8 @@ void push_relabel_max_flow(GraphInterface& gi, size_t src, size_t sink,
{
run_action<graph_tool::detail::always_directed, mpl::true_>()
(gi, bind<void>(get_push_relabel_max_flow(),
_1, gi.GetEdgeIndex(), gi.GetMaxEdgeIndex(),
_1, gi.GetVertexIndex(), gi.GetEdgeIndex(),
gi.GetMaxEdgeIndex(),
src, sink, _2, _3),
edge_scalar_properties(), writable_edge_scalar_properties())
(capacity,res);
......
......@@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "graph_python_interface.hh"
#include "graph.hh"
#include "graph_filtering.hh"
......@@ -24,14 +25,15 @@
# include <boost/tr1/random.hpp>
#endif
#include "graph_rewiring.hh"
#include <boost/bind.hpp>
#include <boost/python.hpp>
#include "graph_rewiring.hh"
using namespace graph_tool;
using namespace boost;
class PythonFuncWrap
{
public:
......
......@@ -73,6 +73,8 @@ public:
const Graph& OriginalGraph() const {return _g;}
Graph& OriginalGraph() {return _g;}
static vertex_descriptor null_vertex() {graph_traits<Graph>::null_vertex();}
private:
Graph& _g;
};
......
......@@ -26,7 +26,7 @@ using namespace std;
using namespace boost;
using namespace graph_tool;
struct graph_copy
struct do_graph_copy
{
template <class GraphDst, class GraphSrc, class DstVertexIndexMap,
class SrcVertexIndexMap, class DstEdgeIndexMap,
......@@ -82,7 +82,7 @@ GraphInterface::GraphInterface(const GraphInterface& gi, bool keep_ref)
run_action<>()
(const_cast<GraphInterface&>(gi),
bind<void>(graph_copy(), _1, ref(_state->_mg),
bind<void>(do_graph_copy(), _1, ref(_state->_mg),
gi._vertex_index, _vertex_index,
gi._edge_index, _edge_index))();
// filters will be copied in python
......
......@@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "graph_python_interface.hh"
#include "graph.hh"
#include "graph_properties.hh"
#include "graph_filtering.hh"
......
......@@ -26,6 +26,14 @@ using namespace std;
using namespace boost;
using namespace graph_tool;
namespace boost
{
size_t hash_value(const boost::python::object& o)
{
return boost::python::extract<size_t>(o.attr("__hash__")());
}
}
namespace graph_tool
{
......
......@@ -18,6 +18,15 @@
#ifndef PYTHON_INTERFACE_HH
#define PYTHON_INTERFACE_HH
#include <boost/python.hpp>
#include <boost/python/type_id.hpp>
namespace boost
{
size_t hash_value(const boost::python::object& o);
}
#include <boost/graph/graph_traits.hpp>
#include <boost/mpl/logical.hpp>
#include <boost/functional/hash.hpp>
......@@ -28,8 +37,6 @@
#include "graph_selectors.hh"
#include "numpy_bind.hh"
#include <boost/python.hpp>
#include <boost/python/type_id.hpp>
// this file includes a simple python interface for the internally kept
// graph. It defines a PythonVertex, PythonEdge and PythonIterator template
......
......@@ -151,6 +151,21 @@ out_degree_no_loops_weighted(typename graph_traits<Graph>::vertex_descriptor v,
}
template <class GraphOrig, class GraphTarget>
void graph_copy(const GraphOrig& g, GraphTarget& gt)
{
typename property_map<GraphOrig, vertex_index_t>::type index = get(vertex_index, g);
typedef typename graph_traits<GraphOrig>::vertex_descriptor vertex_t;
typedef typename graph_traits<GraphTarget>::vertex_descriptor tvertex_t;
vector<tvertex_t> vmap;
typename graph_traits<GraphOrig>::vertex_iterator v, v_end;
for (tie(v, v_end) = vertices(g); v != v_end; ++v)
vmap[index[*v]] = add_vertex(gt);
typename graph_traits<GraphOrig>::edge_iterator e, e_end;
for (tie(e, e_end) = edges(g); e != e_end; ++e)
add_edge(vmap[index[source(*e, g)]], vmap[index[target(*e, g)]], gt);
}
} // namespace graph_tool
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment