Commit ad9dbc5e authored by Tiago Peixoto's avatar Tiago Peixoto

Include support for older versions of GCC (>=4.2)

This enables support for older versions of GCC (>=4.2), by falling back
to the boost tr1 implementation when the GCC version is less than 4.4.
parent b1b71405
...@@ -267,6 +267,9 @@ AC_DEFINE_UNQUOTED([COPYRIGHT], ...@@ -267,6 +267,9 @@ AC_DEFINE_UNQUOTED([COPYRIGHT],
AC_DEFINE([GIT_COMMIT], "esyscmd(git show | head -n 1 | sed 's/commit //' | grep -o -e '.\{8\}' | head -n 1 |tr -d '\n')", [git HEAD commit hash]) AC_DEFINE([GIT_COMMIT], "esyscmd(git show | head -n 1 | sed 's/commit //' | grep -o -e '.\{8\}' | head -n 1 |tr -d '\n')", [git HEAD commit hash])
AC_DEFINE([GIT_COMMIT_DATE], "esyscmd(git log -1 | head -n 3 | grep 'Date:' | sed s/'Date: '// | tr -d '\n')", [git HEAD commit date]) AC_DEFINE([GIT_COMMIT_DATE], "esyscmd(git log -1 | head -n 3 | grep 'Date:' | sed s/'Date: '// | tr -d '\n')", [git HEAD commit date])
# GCC version
AC_DEFINE([GCC_VERSION], [(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)], [GCC version value])
# set some automake variables # set some automake variables
# global CPP flags # global CPP flags
......
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#include "graph_filtering.hh" #include "graph_filtering.hh"
#include "graph_util.hh" #include "graph_util.hh"
#include <tr1/unordered_set>
#include <tr1/tuple>
#include <algorithm> #include <algorithm>
#include <boost/graph/dijkstra_shortest_paths.hpp> #include <boost/graph/dijkstra_shortest_paths.hpp>
......
...@@ -18,7 +18,11 @@ ...@@ -18,7 +18,11 @@
#ifndef GRAPH_CLUSTERING_HH #ifndef GRAPH_CLUSTERING_HH
#define GRAPH_CLUSTERING_HH #define GRAPH_CLUSTERING_HH
#include <tr1/unordered_set> #if (GCC_VERSION >= 40400)
# include <tr1/unordered_set>
#else
# include <boost/tr1/unordered_set.hpp>
#endif
#include <boost/mpl/if.hpp> #include <boost/mpl/if.hpp>
namespace graph_tool namespace graph_tool
......
...@@ -20,7 +20,11 @@ ...@@ -20,7 +20,11 @@
#ifndef GRAPH_EXTENDED_CLUSTERING_HH #ifndef GRAPH_EXTENDED_CLUSTERING_HH
#define GRAPH_EXTENDED_CLUSTERING_HH #define GRAPH_EXTENDED_CLUSTERING_HH
#include <tr1/unordered_set> #if (GCC_VERSION >= 40400)
# include <tr1/unordered_set>
#else
# include <boost/tr1/unordered_set.hpp>
#endif
#include <boost/graph/breadth_first_search.hpp> #include <boost/graph/breadth_first_search.hpp>
namespace graph_tool namespace graph_tool
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include "graph_motifs.hh" #include "graph_motifs.hh"
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/ref.hpp>
using namespace std; using namespace std;
using namespace boost; using namespace boost;
...@@ -89,7 +88,7 @@ void get_motifs(GraphInterface& g, size_t k, python::list subgraph_list, ...@@ -89,7 +88,7 @@ void get_motifs(GraphInterface& g, size_t k, python::list subgraph_list,
GraphInterface& sub = GraphInterface& sub =
python::extract<GraphInterface&>(subgraph_list[i]); python::extract<GraphInterface&>(subgraph_list[i]);
run_action<>()(sub, bind<void>(append_to_list(), _1, run_action<>()(sub, bind<void>(append_to_list(), _1,
ref(list)))(); boost::ref(list)))();
} }
} }
catch (bad_any_cast&) catch (bad_any_cast&)
...@@ -114,8 +113,9 @@ void get_motifs(GraphInterface& g, size_t k, python::list subgraph_list, ...@@ -114,8 +113,9 @@ void get_motifs(GraphInterface& g, size_t k, python::list subgraph_list,
sampler = sample_some(plist, rng); sampler = sample_some(plist, rng);
run_action<>() run_action<>()
(g, bind<void>(get_all_motifs(), _1, k, ref(list), ref(phist), _2, (g, boost::bind<void>(get_all_motifs(), _1, k, boost::ref(list),
plist[0], comp_iso, fill_list, ref(rng)), boost::ref(phist), _2,
plist[0], comp_iso, fill_list, boost::ref(rng)),
mpl::vector<sample_all,sample_some>())(sampler); mpl::vector<sample_all,sample_some>())(sampler);
for (size_t i = 0; i < phist.size(); ++i) for (size_t i = 0; i < phist.size(); ++i)
...@@ -138,8 +138,8 @@ void get_motifs(GraphInterface& g, size_t k, python::list subgraph_list, ...@@ -138,8 +138,8 @@ void get_motifs(GraphInterface& g, size_t k, python::list subgraph_list,
mpl::bool_<false>,mpl::bool_<true>, mpl::bool_<false>,mpl::bool_<true>,
mpl::bool_<true> >::type gviews; mpl::bool_<true> >::type gviews;
run_action<gviews>() run_action<gviews>()
(sub, bind<void>(retrieve_from_list(), _1, (sub, boost::bind<void>(retrieve_from_list(), _1,
ref(list), ref(done)))(); boost::ref(list), boost::ref(done)))();
if (!done) if (!done)
{ {
sub.ReIndexEdges(); sub.ReIndexEdges();
......
...@@ -18,11 +18,16 @@ ...@@ -18,11 +18,16 @@
#ifndef GRAPH_MOTIFS_HH #ifndef GRAPH_MOTIFS_HH
#define GRAPH_MOTIFS_HH #define GRAPH_MOTIFS_HH
#include <boost/functional/hash.hpp>
#include <boost/graph/copy.hpp> #include <boost/graph/copy.hpp>
#include <boost/graph/isomorphism.hpp> #include <boost/graph/isomorphism.hpp>
#include <tr1/unordered_map> #if (GCC_VERSION >= 40400)
#include <tr1/random> # include <tr1/unordered_set>
# include <tr1/random>
#else
# include <boost/tr1/unordered_set.hpp>
# include <boost/tr1/random.hpp>
#endif
#include <boost/functional/hash.hpp>
#include <algorithm> #include <algorithm>
namespace graph_tool namespace graph_tool
......
...@@ -18,9 +18,15 @@ ...@@ -18,9 +18,15 @@
#ifndef GRAPH_COMMUNITY_HH #ifndef GRAPH_COMMUNITY_HH
#define GRAPH_COMMUNITY_HH #define GRAPH_COMMUNITY_HH
#include <tr1/random> #if (GCC_VERSION >= 40400)
#include <tr1/unordered_set> # include <tr1/unordered_set>
#include <tr1/tuple> # include <tr1/random>
# include <tr1/tuple>
#else
# include <boost/tr1/unordered_set.hpp>
# include <boost/tr1/random.hpp>
# include <boost/tr1/tuple.hpp>
#endif
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <iomanip> #include <iomanip>
......
...@@ -18,7 +18,11 @@ ...@@ -18,7 +18,11 @@
#ifndef GRAPH_COMMUNITY_NETWORK_HH #ifndef GRAPH_COMMUNITY_NETWORK_HH
#define GRAPH_COMMUNITY_NETWORK_HH #define GRAPH_COMMUNITY_NETWORK_HH
#include <tr1/unordered_set> #if (GCC_VERSION >= 40400)
# include <tr1/unordered_map>
#else
# include <boost/tr1/unordered_map.hpp>
#endif
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
...@@ -49,14 +53,14 @@ struct get_community_network ...@@ -49,14 +53,14 @@ struct get_community_network
typedef typename boost::property_traits<CommunityMap>::value_type typedef typename boost::property_traits<CommunityMap>::value_type
s_type; s_type;
tr1::unordered_map<s_type, vector<vertex_t>, boost::hash<s_type> > tr1::unordered_map<s_type, vector<vertex_t>, hash<s_type> >
comms; comms;
typename graph_traits<Graph>::vertex_iterator v, v_end; typename graph_traits<Graph>::vertex_iterator v, v_end;
for (tie(v, v_end) = vertices(g); v != v_end; ++v) for (tie(v, v_end) = vertices(g); v != v_end; ++v)
comms[get(s_map, *v)].push_back(*v); comms[get(s_map, *v)].push_back(*v);
// create vertices // create vertices
tr1::unordered_map<s_type, cvertex_t, boost::hash<s_type> > tr1::unordered_map<s_type, cvertex_t, hash<s_type> >
comm_vertices; comm_vertices;
for (typeof(comms.begin()) iter = comms.begin(); iter != comms.end(); for (typeof(comms.begin()) iter = comms.begin(); iter != comms.end();
++iter) ++iter)
...@@ -68,7 +72,7 @@ struct get_community_network ...@@ -68,7 +72,7 @@ struct get_community_network
// create edges // create edges
tr1::unordered_map<pair<size_t, size_t>, tr1::unordered_map<pair<size_t, size_t>,
cedge_t, boost::hash<pair<size_t, size_t> > > cedge_t, hash<pair<size_t, size_t> > >
comm_edges; comm_edges;
for (typeof(comms.begin()) iter = comms.begin(); iter != comms.end(); for (typeof(comms.begin()) iter = comms.begin(); iter != comms.end();
++iter) ++iter)
......
...@@ -18,7 +18,12 @@ ...@@ -18,7 +18,12 @@
#ifndef GRAPH_ASSORTATIVITY_HH #ifndef GRAPH_ASSORTATIVITY_HH
#define GRAPH_ASSORTATIVITY_HH #define GRAPH_ASSORTATIVITY_HH
#include <tr1/unordered_set>
#if (GCC_VERSION >= 40400)
# include <tr1/unordered_map>
#else
# include <boost/tr1/unordered_map.hpp>
#endif
#include "shared_map.hh" #include "shared_map.hh"
#include "graph_util.hh" #include "graph_util.hh"
......
...@@ -18,10 +18,16 @@ ...@@ -18,10 +18,16 @@
#ifndef GRAPH_GENERATION_HH #ifndef GRAPH_GENERATION_HH
#define GRAPH_GENERATION_HH #define GRAPH_GENERATION_HH
#if (GCC_VERSION >= 40400)
# include <tr1/unordered_map>
# include <tr1/random>
# include <tr1/tuple>
#else
# include <boost/tr1/unordered_map.hpp>
# include <boost/tr1/random.hpp>
# include <boost/tr1/tuple.hpp>
#endif
#include <boost/functional/hash.hpp> #include <boost/functional/hash.hpp>
#include <tr1/unordered_set>
#include <tr1/unordered_map>
#include <tr1/random>
#include <map> #include <map>
#include <set> #include <set>
#include <iostream> #include <iostream>
...@@ -478,7 +484,7 @@ struct gen_random_graph ...@@ -478,7 +484,7 @@ struct gen_random_graph
// vertices with a given degree // vertices with a given degree
tr1::unordered_map<deg_t, vector<size_t>, tr1::unordered_map<deg_t, vector<size_t>,
boost::hash<deg_t> > vset; hash<deg_t> > vset;
size_t num_e = 0; size_t num_e = 0;
for (size_t i = 0; i < vertices.size(); ++i) for (size_t i = 0; i < vertices.size(); ++i)
......
...@@ -19,15 +19,6 @@ ...@@ -19,15 +19,6 @@
#include "graph.hh" #include "graph.hh"
#include "graph_properties.hh" #include "graph_properties.hh"
#include <tr1/unordered_set>
#include <iostream>
#include <iomanip>
#include <boost/algorithm/string.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#include <boost/iostreams/filter/bzip2.hpp>
#include <boost/iostreams/device/file.hpp>
using namespace std; using namespace std;
using namespace boost; using namespace boost;
using namespace graph_tool; using namespace graph_tool;
......
...@@ -18,7 +18,11 @@ ...@@ -18,7 +18,11 @@
#include "graph.hh" #include "graph.hh"
#include "graph_filtering.hh" #include "graph_filtering.hh"
#include <tr1/random> #if (GCC_VERSION >= 40400)
# include <tr1/random>
#else
# include <boost/tr1/random.hpp>
#endif
#include "graph_rewiring.hh" #include "graph_rewiring.hh"
...@@ -53,24 +57,28 @@ void random_rewire(GraphInterface& gi, string strat, bool self_loops, ...@@ -53,24 +57,28 @@ void random_rewire(GraphInterface& gi, string strat, bool self_loops,
if (strat == "erdos") if (strat == "erdos")
run_action<graph_tool::detail::never_reversed>() run_action<graph_tool::detail::never_reversed>()
(gi, bind<void>(graph_rewire<ErdosRewireStrategy>(), (gi, boost::bind<void>(graph_rewire<ErdosRewireStrategy>(),
_1, gi.GetEdgeIndex(), ref(corr), ref(rng), _1, gi.GetEdgeIndex(), boost::ref(corr),
self_loops, parallel_edges, verbose))(); boost::ref(rng), self_loops, parallel_edges,
verbose))();
else if (strat == "uncorrelated") else if (strat == "uncorrelated")
run_action<graph_tool::detail::never_reversed>() run_action<graph_tool::detail::never_reversed>()
(gi, bind<void>(graph_rewire<RandomRewireStrategy>(), (gi, boost::bind<void>(graph_rewire<RandomRewireStrategy>(),
_1, gi.GetEdgeIndex(), ref(corr), ref(rng), _1, gi.GetEdgeIndex(), boost::ref(corr),
self_loops, parallel_edges, verbose))(); boost::ref(rng), self_loops, parallel_edges,
verbose))();
else if (strat == "correlated") else if (strat == "correlated")
run_action<graph_tool::detail::never_reversed>() run_action<graph_tool::detail::never_reversed>()
(gi, bind<void>(graph_rewire<CorrelatedRewireStrategy>(), (gi, boost::bind<void>(graph_rewire<CorrelatedRewireStrategy>(),
_1, gi.GetEdgeIndex(), ref(corr), ref(rng), _1, gi.GetEdgeIndex(), boost::ref(corr),
self_loops, parallel_edges, verbose))(); boost::ref(rng), self_loops, parallel_edges,
verbose))();
else if (strat == "probabilistic") else if (strat == "probabilistic")
run_action<>() run_action<>()
(gi, bind<void>(graph_rewire<ProbabilisticRewireStrategy>(), (gi, boost::bind<void>(graph_rewire<ProbabilisticRewireStrategy>(),
_1, gi.GetEdgeIndex(), ref(corr), ref(rng), _1, gi.GetEdgeIndex(), boost::ref(corr),
self_loops, parallel_edges, verbose))(); boost::ref(rng), self_loops, parallel_edges,
verbose))();
else else
throw ValueException("invalid random rewire strategy: " + strat); throw ValueException("invalid random rewire strategy: " + strat);
} }
...@@ -18,9 +18,15 @@ ...@@ -18,9 +18,15 @@
#ifndef GRAPH_REWIRING_HH #ifndef GRAPH_REWIRING_HH
#define GRAPH_REWIRING_HH #define GRAPH_REWIRING_HH
#include <tr1/unordered_set> #if (GCC_VERSION >= 40400)
#include <tr1/random> # include <tr1/unordered_set>
# include <tr1/random>
#else
# include <boost/tr1/unordered_set.hpp>
# include <boost/tr1/random.hpp>
#endif
#include <boost/functional/hash.hpp> #include <boost/functional/hash.hpp>
#include <iostream> #include <iostream>
#include <boost/multi_index_container.hpp> #include <boost/multi_index_container.hpp>
...@@ -700,7 +706,8 @@ public: ...@@ -700,7 +706,8 @@ public:
private: private:
typedef tr1::unordered_map<pair<size_t, size_t>, typedef tr1::unordered_map<pair<size_t, size_t>,
vector<pair<index_t, bool> >, vector<pair<index_t, bool> >,
hash<pair<size_t, size_t> > > edges_by_end_deg_t; hash<pair<size_t, size_t> > >
edges_by_end_deg_t;
edges_by_end_deg_t _edges_by_source, _edges_by_target; edges_by_end_deg_t _edges_by_source, _edges_by_target;
protected: protected:
......
...@@ -20,6 +20,11 @@ ...@@ -20,6 +20,11 @@
// follow the requirements of the GNU GPL in regard to all of the // follow the requirements of the GNU GPL in regard to all of the
// software in the executable aside from CGAL. // software in the executable aside from CGAL.
#if (GCC_VERSION < 40400)
# define CGAL_CFG_NO_TR1_ARRAY
# define CGAL_CFG_NO_TR1_TUPLE
#endif
#include <CGAL/version.h> #include <CGAL/version.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Triangulation_3.h> #include <CGAL/Triangulation_3.h>
...@@ -28,7 +33,6 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; ...@@ -28,7 +33,6 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Triangulation_3<Kernel> SimpleTriangulation; typedef CGAL::Triangulation_3<Kernel> SimpleTriangulation;
typedef CGAL::Delaunay_triangulation_3<Kernel> DelaunayTriangulation; typedef CGAL::Delaunay_triangulation_3<Kernel> DelaunayTriangulation;
namespace std namespace std
{ {
bool operator==(const SimpleTriangulation::Vertex& a, bool operator==(const SimpleTriangulation::Vertex& a,
...@@ -56,9 +60,9 @@ bool operator==(const PeriodicDelaunayTriangulation::Vertex& a, ...@@ -56,9 +60,9 @@ bool operator==(const PeriodicDelaunayTriangulation::Vertex& a,
#endif #endif
#include "graph.hh" #include "graph.hh"
#include "graph_triangulation.hh"
#include "graph_util.hh" #include "graph_util.hh"
#include "graph_filtering.hh" #include "graph_filtering.hh"
#include "graph_triangulation.hh"
#include "numpy_bind.hh" #include "numpy_bind.hh"
using namespace std; using namespace std;
......
...@@ -23,7 +23,15 @@ ...@@ -23,7 +23,15 @@
#ifndef GRAPH_TRIANGULATION_HH #ifndef GRAPH_TRIANGULATION_HH
#define GRAPH_TRIANGULATION_HH #define GRAPH_TRIANGULATION_HH
#include <tr1/unordered_map> #if (GCC_VERSION >= 40400)
# include <tr1/unordered_set>
# include <tr1/random>
# include <tr1/tuple>
#else
# include <boost/tr1/unordered_set.hpp>
# include <boost/tr1/random.hpp>
# include <boost/tr1/tuple.hpp>
#endif
#include <boost/functional/hash.hpp> #include <boost/functional/hash.hpp>
#include "graph_util.hh" #include "graph_util.hh"
......
...@@ -18,10 +18,6 @@ ...@@ -18,10 +18,6 @@
#ifndef GRAPH_REWIRING_HH #ifndef GRAPH_REWIRING_HH
#define GRAPH_REWIRING_HH #define GRAPH_REWIRING_HH
#include <tr1/unordered_set>
#include <tr1/random>
#include <boost/functional/hash.hpp>
#include "graph.hh" #include "graph.hh"
#include "graph_filtering.hh" #include "graph_filtering.hh"
#include "graph_util.hh" #include "graph_util.hh"
......
...@@ -18,7 +18,11 @@ ...@@ -18,7 +18,11 @@
#ifndef SAMPLER_HH #ifndef SAMPLER_HH
#define SAMPLER_HH #define SAMPLER_HH
#include <tr1/random> #if (GCC_VERSION >= 40400)
# include <tr1/random>
#else
# include <boost/tr1/random.hpp>
#endif
#include <iostream> #include <iostream>
namespace graph_tool namespace graph_tool
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#ifndef GRAPH_HH #ifndef GRAPH_HH
#define GRAPH_HH #define GRAPH_HH
#include "config.h"
#include <deque> #include <deque>
...@@ -29,7 +30,6 @@ ...@@ -29,7 +30,6 @@
#include <boost/python/dict.hpp> #include <boost/python/dict.hpp>
#include <boost/mpl/vector.hpp> #include <boost/mpl/vector.hpp>
#include "graph_properties.hh" #include "graph_properties.hh"
#include "config.h"
namespace graph_tool namespace graph_tool
{ {
......
...@@ -264,9 +264,9 @@ template <class IndexMap> ...@@ -264,9 +264,9 @@ template <class IndexMap>
python::object find_property_map(dynamic_property_map* map, IndexMap) python::object find_property_map(dynamic_property_map* map, IndexMap)
{ {
python::object pmap; python::object pmap;
mpl::for_each<value_types>(bind<void>(get_python_property(), mpl::for_each<value_types>(boost::bind<void>(get_python_property(),
_1, IndexMap(), ref(map), _1, IndexMap(), ref(map),
ref(pmap))); boost::ref(pmap)));
return pmap; return pmap;
} }
...@@ -670,20 +670,22 @@ void GraphInterface::WriteToFile(string file, python::object pfile, ...@@ -670,20 +670,22 @@ void GraphInterface::WriteToFile(string file, python::object pfile,
typedef tr1::unordered_map<vertex_t, size_t> map_t; typedef tr1::unordered_map<vertex_t, size_t> map_t;
map_t vertex_to_index; map_t vertex_to_index;
associative_property_map<map_t> index_map(vertex_to_index); associative_property_map<map_t> index_map(vertex_to_index);
run_action<>()(*this, bind<void>(generate_index(), run_action<>()(*this, boost::bind<void>(generate_index(),
_1, index_map))(); _1, index_map))();
if (graphviz) if (graphviz)
graphviz_insert_index(dp, index_map); graphviz_insert_index(dp, index_map);
if (GetDirected()) if (GetDirected())
run_action<detail::always_directed>() run_action<detail::always_directed>()
(*this, bind<void>(write_to_file(), ref(stream), _1, (*this, boost::bind<void>(write_to_file(),
index_map, ref(dp), graphviz))(); boost::ref(stream), _1,
index_map, boost::ref(dp),
graphviz))();
else else
run_action<detail::never_directed>() run_action<detail::never_directed>()
(*this,bind<void>(write_to_file_fake_undir(), (*this,boost::bind<void>(write_to_file_fake_undir(),
ref(stream), _1, index_map, boost::ref(stream), _1, index_map,
ref(dp), graphviz))(); boost::ref(dp), graphviz))();
} }
else else
{ {
...@@ -692,13 +694,16 @@ void GraphInterface::WriteToFile(string file, python::object pfile, ...@@ -692,13 +694,16 @@ void GraphInterface::WriteToFile(string file, python::object pfile,
if (GetDirected()) if (GetDirected())
run_action<detail::always_directed>() run_action<detail::always_directed>()
(*this, bind<void>(write_to_file(), ref(stream), _1, (*this, boost::bind<void>(write_to_file(),
_vertex_index, ref(dp), graphviz))(); boost::ref(stream), _1,
_vertex_index, boost::ref(dp),
graphviz))();
else else
run_action<detail::never_directed>() run_action<detail::never_directed>()
(*this,bind<void>(write_to_file_fake_undir(), (*this,boost::bind<void>(write_to_file_fake_undir(),
ref(stream), _1, _vertex_index, boost::ref(stream), _1,
ref(dp), graphviz))(); _vertex_index, boost::ref(dp),
graphviz))();
} }
stream.reset(); stream.reset();
} }