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],
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])
# GCC version
AC_DEFINE([GCC_VERSION], [(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)], [GCC version value])
# set some automake variables
# global CPP flags
......
......@@ -22,8 +22,6 @@
#include "graph_filtering.hh"
#include "graph_util.hh"
#include <tr1/unordered_set>
#include <tr1/tuple>
#include <algorithm>
#include <boost/graph/dijkstra_shortest_paths.hpp>
......
......@@ -18,7 +18,11 @@
#ifndef 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>
namespace graph_tool
......
......@@ -20,7 +20,11 @@
#ifndef 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>
namespace graph_tool
......
......@@ -24,7 +24,6 @@
#include "graph_motifs.hh"
#include <boost/python.hpp>
#include <boost/ref.hpp>
using namespace std;
using namespace boost;
......@@ -89,7 +88,7 @@ void get_motifs(GraphInterface& g, size_t k, python::list subgraph_list,
GraphInterface& sub =
python::extract<GraphInterface&>(subgraph_list[i]);
run_action<>()(sub, bind<void>(append_to_list(), _1,
ref(list)))();
boost::ref(list)))();
}
}
catch (bad_any_cast&)
......@@ -114,8 +113,9 @@ void get_motifs(GraphInterface& g, size_t k, python::list subgraph_list,
sampler = sample_some(plist, rng);
run_action<>()
(g, bind<void>(get_all_motifs(), _1, k, ref(list), ref(phist), _2,
plist[0], comp_iso, fill_list, ref(rng)),
(g, boost::bind<void>(get_all_motifs(), _1, k, boost::ref(list),
boost::ref(phist), _2,
plist[0], comp_iso, fill_list, boost::ref(rng)),
mpl::vector<sample_all,sample_some>())(sampler);
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,
mpl::bool_<false>,mpl::bool_<true>,
mpl::bool_<true> >::type gviews;
run_action<gviews>()
(sub, bind<void>(retrieve_from_list(), _1,
ref(list), ref(done)))();
(sub, boost::bind<void>(retrieve_from_list(), _1,
boost::ref(list), boost::ref(done)))();
if (!done)
{
sub.ReIndexEdges();
......
......@@ -18,11 +18,16 @@
#ifndef GRAPH_MOTIFS_HH
#define GRAPH_MOTIFS_HH
#include <boost/functional/hash.hpp>
#include <boost/graph/copy.hpp>
#include <boost/graph/isomorphism.hpp>
#include <tr1/unordered_map>
#include <tr1/random>
#if (GCC_VERSION >= 40400)
# 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>
namespace graph_tool
......
......@@ -18,9 +18,15 @@
#ifndef GRAPH_COMMUNITY_HH
#define GRAPH_COMMUNITY_HH
#include <tr1/random>
#include <tr1/unordered_set>
#include <tr1/tuple>
#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 <iostream>
#include <fstream>
#include <iomanip>
......
......@@ -18,7 +18,11 @@
#ifndef 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 <iomanip>
......@@ -49,14 +53,14 @@ struct get_community_network
typedef typename boost::property_traits<CommunityMap>::value_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;
typename graph_traits<Graph>::vertex_iterator v, v_end;
for (tie(v, v_end) = vertices(g); v != v_end; ++v)
comms[get(s_map, *v)].push_back(*v);
// 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;
for (typeof(comms.begin()) iter = comms.begin(); iter != comms.end();
++iter)
......@@ -68,7 +72,7 @@ struct get_community_network
// create edges
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;
for (typeof(comms.begin()) iter = comms.begin(); iter != comms.end();
++iter)
......
......@@ -18,7 +18,12 @@
#ifndef 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 "graph_util.hh"
......
......@@ -18,10 +18,16 @@
#ifndef 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 <tr1/unordered_set>
#include <tr1/unordered_map>
#include <tr1/random>
#include <map>
#include <set>
#include <iostream>
......@@ -478,7 +484,7 @@ struct gen_random_graph
// vertices with a given degree
tr1::unordered_map<deg_t, vector<size_t>,
boost::hash<deg_t> > vset;
hash<deg_t> > vset;
size_t num_e = 0;
for (size_t i = 0; i < vertices.size(); ++i)
......
......@@ -19,15 +19,6 @@
#include "graph.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 boost;
using namespace graph_tool;
......
......@@ -18,7 +18,11 @@
#include "graph.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"
......@@ -53,24 +57,28 @@ void random_rewire(GraphInterface& gi, string strat, bool self_loops,
if (strat == "erdos")
run_action<graph_tool::detail::never_reversed>()
(gi, bind<void>(graph_rewire<ErdosRewireStrategy>(),
_1, gi.GetEdgeIndex(), ref(corr), ref(rng),
self_loops, parallel_edges, verbose))();
(gi, boost::bind<void>(graph_rewire<ErdosRewireStrategy>(),
_1, gi.GetEdgeIndex(), boost::ref(corr),
boost::ref(rng), self_loops, parallel_edges,
verbose))();
else if (strat == "uncorrelated")
run_action<graph_tool::detail::never_reversed>()
(gi, bind<void>(graph_rewire<RandomRewireStrategy>(),
_1, gi.GetEdgeIndex(), ref(corr), ref(rng),
self_loops, parallel_edges, verbose))();
(gi, boost::bind<void>(graph_rewire<RandomRewireStrategy>(),
_1, gi.GetEdgeIndex(), boost::ref(corr),
boost::ref(rng), self_loops, parallel_edges,
verbose))();
else if (strat == "correlated")
run_action<graph_tool::detail::never_reversed>()
(gi, bind<void>(graph_rewire<CorrelatedRewireStrategy>(),
_1, gi.GetEdgeIndex(), ref(corr), ref(rng),
self_loops, parallel_edges, verbose))();
(gi, boost::bind<void>(graph_rewire<CorrelatedRewireStrategy>(),
_1, gi.GetEdgeIndex(), boost::ref(corr),
boost::ref(rng), self_loops, parallel_edges,
verbose))();
else if (strat == "probabilistic")
run_action<>()
(gi, bind<void>(graph_rewire<ProbabilisticRewireStrategy>(),
_1, gi.GetEdgeIndex(), ref(corr), ref(rng),
self_loops, parallel_edges, verbose))();
(gi, boost::bind<void>(graph_rewire<ProbabilisticRewireStrategy>(),
_1, gi.GetEdgeIndex(), boost::ref(corr),
boost::ref(rng), self_loops, parallel_edges,
verbose))();
else
throw ValueException("invalid random rewire strategy: " + strat);
}
......@@ -18,9 +18,15 @@
#ifndef GRAPH_REWIRING_HH
#define GRAPH_REWIRING_HH
#include <tr1/unordered_set>
#include <tr1/random>
#if (GCC_VERSION >= 40400)
# 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 <iostream>
#include <boost/multi_index_container.hpp>
......@@ -700,7 +706,8 @@ public:
private:
typedef tr1::unordered_map<pair<size_t, size_t>,
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;
protected:
......
......@@ -20,6 +20,11 @@
// follow the requirements of the GNU GPL in regard to all of the
// 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/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Triangulation_3.h>
......@@ -28,7 +33,6 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Triangulation_3<Kernel> SimpleTriangulation;
typedef CGAL::Delaunay_triangulation_3<Kernel> DelaunayTriangulation;
namespace std
{
bool operator==(const SimpleTriangulation::Vertex& a,
......@@ -56,9 +60,9 @@ bool operator==(const PeriodicDelaunayTriangulation::Vertex& a,
#endif
#include "graph.hh"
#include "graph_triangulation.hh"
#include "graph_util.hh"
#include "graph_filtering.hh"
#include "graph_triangulation.hh"
#include "numpy_bind.hh"
using namespace std;
......
......@@ -23,7 +23,15 @@
#ifndef 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 "graph_util.hh"
......
......@@ -18,10 +18,6 @@
#ifndef GRAPH_REWIRING_HH
#define GRAPH_REWIRING_HH
#include <tr1/unordered_set>
#include <tr1/random>
#include <boost/functional/hash.hpp>
#include "graph.hh"
#include "graph_filtering.hh"
#include "graph_util.hh"
......
......@@ -18,7 +18,11 @@
#ifndef SAMPLER_HH
#define SAMPLER_HH
#include <tr1/random>
#if (GCC_VERSION >= 40400)
# include <tr1/random>
#else
# include <boost/tr1/random.hpp>
#endif
#include <iostream>
namespace graph_tool
......
......@@ -17,6 +17,7 @@
#ifndef GRAPH_HH
#define GRAPH_HH
#include "config.h"
#include <deque>
......@@ -29,7 +30,6 @@
#include <boost/python/dict.hpp>
#include <boost/mpl/vector.hpp>
#include "graph_properties.hh"
#include "config.h"
namespace graph_tool
{
......
......@@ -264,9 +264,9 @@ template <class IndexMap>
python::object find_property_map(dynamic_property_map* map, IndexMap)
{
python::object pmap;
mpl::for_each<value_types>(bind<void>(get_python_property(),
_1, IndexMap(), ref(map),
ref(pmap)));
mpl::for_each<value_types>(boost::bind<void>(get_python_property(),
_1, IndexMap(), ref(map),
boost::ref(pmap)));
return pmap;
}
......@@ -670,20 +670,22 @@ void GraphInterface::WriteToFile(string file, python::object pfile,
typedef tr1::unordered_map<vertex_t, size_t> map_t;
map_t vertex_to_index;
associative_property_map<map_t> index_map(vertex_to_index);
run_action<>()(*this, bind<void>(generate_index(),
_1, index_map))();
run_action<>()(*this, boost::bind<void>(generate_index(),
_1, index_map))();
if (graphviz)
graphviz_insert_index(dp, index_map);
if (GetDirected())
run_action<detail::always_directed>()
(*this, bind<void>(write_to_file(), ref(stream), _1,
index_map, ref(dp), graphviz))();
(*this, boost::bind<void>(write_to_file(),
boost::ref(stream), _1,
index_map, boost::ref(dp),
graphviz))();
else
run_action<detail::never_directed>()
(*this,bind<void>(write_to_file_fake_undir(),
ref(stream), _1, index_map,
ref(dp), graphviz))();
(*this,boost::bind<void>(write_to_file_fake_undir(),
boost::ref(stream), _1, index_map,
boost::ref(dp), graphviz))();
}
else
{
......@@ -692,13 +694,16 @@ void GraphInterface::WriteToFile(string file, python::object pfile,
if (GetDirected())
run_action<detail::always_directed>()
(*this, bind<void>(write_to_file(), ref(stream), _1,
_vertex_index, ref(dp), graphviz))();
(*this, boost::bind<void>(write_to_file(),
boost::ref(stream), _1,
_vertex_index, boost::ref(dp),
graphviz))();
else
run_action<detail::never_directed>()
(*this,bind<void>(write_to_file_fake_undir(),
ref(stream), _1, _vertex_index,
ref(dp), graphviz))();
(*this,boost::bind<void>(write_to_file_fake_undir(),
boost::ref(stream), _1,
_vertex_index, boost::ref(dp),
graphviz))();
}
stream.reset();
}
......
......@@ -20,8 +20,18 @@
#include <string>
#include <vector>
#include <tr1/unordered_map>
#include <tr1/memory>
#if (GCC_VERSION >= 40400)
# include <tr1/unordered_set>
# include <tr1/unordered_map>
# include <tr1/random>
# include <tr1/memory>
#else
# include <boost/tr1/unordered_set.hpp>
# include <boost/tr1/unordered_map.hpp>
# include <boost/tr1/random.hpp>
# include <boost/tr1/memory.hpp>
#endif
#include <boost/functional/hash.hpp>
#include <boost/python/object.hpp>
#include <boost/version.hpp>
......@@ -33,7 +43,6 @@
# include <boost/dynamic_property_map.hpp>
#endif
#include "fast_vector_property_map.hh"
#include <boost/functional/hash.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/for_each.hpp>
#include <boost/mpl/transform.hpp>
......
......@@ -207,7 +207,8 @@ struct get_edge_descriptor
pe.SetValid(false);
typename graph_traits<Graph>::out_edge_iterator e_begin, e_end;
tie(e_begin, e_end) = out_edges(source(pe.GetDescriptor(),g),g);
e_begin = std::find(e_begin, e_end, pe.GetDescriptor());
while(e_begin != e_end && *e_begin != pe.GetDescriptor())
++e_begin;
if (e_begin == e_end)
return; // invalid edge descriptor
edge = pe.GetDescriptor();
......
......@@ -28,6 +28,7 @@
#include <boost/algorithm/string/trim.hpp>
#include <boost/xpressive/xpressive.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <string>
namespace graph_tool
......
......@@ -224,7 +224,7 @@ inline void clear_vertex
typename graph_traits<graph_t>::out_edge_iterator e, e_end;
for (tie(e,e_end) == out_edges(u, g); e != e_end; ++e)
del_es.push_back(*e);
if (is_directed::apply<graph_t>::type::value)
if (graph_tool::is_directed::apply<graph_t>::type::value)
{
typename in_edge_iteratorS<graph_t>::type e, e_end;
for (tie(e,e_end) == in_edge_iteratorS<graph_t>::get_edges(u, g);
......
......@@ -18,7 +18,11 @@
#ifndef GRAPH_ARF_HH
#define GRAPH_ARF_HH
#include <tr1/random>
#if (GCC_VERSION >= 40400)
# include <tr1/random>
#else
# include <boost/tr1/random.hpp>
#endif
#include <limits>
#include <iostream>
......
......@@ -18,7 +18,11 @@
#ifndef SHARED_MAP_HH
#define SHARED_MAP_HH
#include <tr1/unordered_set>
#if (GCC_VERSION >= 40400)
# include <tr1/unordered_set>
#else
# include <boost/tr1/unordered_set.hpp>
#endif
// This class will encapsulate a map, and atomically sum it to a given resulting
// map (which is shared among all copies) after it is destructed, or when the
......
......@@ -41,16 +41,18 @@ python::object sampled_distance_histogram(GraphInterface& gi, boost::any weight,
if (weight.empty())
{
run_action<>()(gi,
bind<void>(get_sampled_distance_histogram(), _1,
gi.GetVertexIndex(), no_weightS(), n_samples,
ref(bins), ref(ret), ref(rng)))();
boost::bind<void>(get_sampled_distance_histogram(), _1,
gi.GetVertexIndex(), no_weightS(),
n_samples, boost::ref(bins),
boost::ref(ret), boost::ref(rng)))();
}
else
{
run_action<>()(gi,
bind<void>(get_sampled_distance_histogram(), _1,
gi.GetVertexIndex(), _2, n_samples,
ref(bins), ref(ret), ref(rng)),
boost::bind<void>(get_sampled_distance_histogram(), _1,
gi.GetVertexIndex(), _2, n_samples,
boost::ref(bins), boost::ref(ret),
boost::ref(rng)),
edge_scalar_properties())(weight);
}
return ret;
......
......@@ -25,7 +25,11 @@
#include <boost/python/list.hpp>
#include <boost/python/extract.hpp>
#include <tr1/random>
#if (GCC_VERSION >= 40400)
# include <tr1/random>
#else
# include <boost/tr1/random.hpp>
#endif
#include "histogram.hh"
#include "numpy_bind.hh"
......
......@@ -16,7 +16,11 @@
#ifndef GRAPH_PARALLEL_HH
#define GRAPH_PARALLEL_HH
#include <tr1/unordered_set>
#if (GCC_VERSION >= 40400)
# include <tr1/unordered_set>
#else
# include <boost/tr1/unordered_set.hpp>
#endif
#include "graph_util.hh"
namespace graph_tool
......
......@@ -20,8 +20,13 @@
#include <boost/graph/graph_traits.hpp>
#include <utility>
#include <tr1/unordered_set>
#include <tr1/random>
#if (GCC_VERSION >= 40400)
# include <tr1/unordered_set>
# include <tr1/random>
#else
# include <boost/tr1/unordered_set.hpp>
# include <boost/tr1/random.hpp>
#endif
namespace boost
{
......@@ -175,7 +180,7 @@ bool refine_check(const Graph1& sub, const Graph2& g, matrix_t& M, size_t count,
bool valid = check_adjacency()
(vertex(k, sub), vertex(vlist[l], g), M, edge_labelling,
sub, g, vindex,
typename is_directed::apply<Graph1>::type());
typename graph_tool::is_directed::apply<Graph1>::type());
if (valid)
m_new.insert(l);
}
......
......@@ -19,7 +19,11 @@
#include "graph_python_interface.hh"
#include "graph_util.hh"
#include <tr1/unordered_set>
#if (GCC_VERSION >= 40400)
# include <tr1/unordered_set>
#else
# include <boost/tr1/unordered_set.hpp>
#endif