Commit 1ac66242 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Avoid global inclusion of std and boost namespaces

parent d933fe7e
......@@ -315,10 +315,10 @@ namespace detail { namespace graph {
init_centrality_map(vertices(g), centrality);
init_centrality_map(edges(g), edge_centrality_map);
vector<typename property_traits<IncomingMap>::value_type> vincoming(num_vertices(g));
vector<typename property_traits<DistanceMap>::value_type> vdistance(num_vertices(g));
vector<typename property_traits<DependencyMap>::value_type> vdependency(num_vertices(g));
vector<typename property_traits<PathCountMap>::value_type> vpath_count(num_vertices(g));
std::vector<typename property_traits<IncomingMap>::value_type> vincoming(num_vertices(g));
std::vector<typename property_traits<DistanceMap>::value_type> vdistance(num_vertices(g));
std::vector<typename property_traits<DependencyMap>::value_type> vdependency(num_vertices(g));
std::vector<typename property_traits<PathCountMap>::value_type> vpath_count(num_vertices(g));
int i, N = num_vertices(g);
#pragma omp parallel for default(shared) private(i) \
......
......@@ -41,6 +41,7 @@ Value power(Value value, int n)
namespace graph_tool
{
using namespace boost;
using namespace std;
// calculates the number of triangles to which v belongs
template <class Graph, class VProp>
......
......@@ -26,14 +26,12 @@
#include "graph_python_interface.hh"
#include <boost/python.hpp>
using namespace std;
using namespace graph_tool;
struct append_to_list
{
template <class Graph>
void operator()(Graph& g, vector<d_graph_t>& glist) const
void operator()(Graph& g, std::vector<d_graph_t>& glist) const
{
glist.emplace_back();
graph_copy(g, glist.back());
......@@ -43,7 +41,7 @@ struct append_to_list
struct retrieve_from_list
{
template <class Graph>
void operator()(Graph& g, vector<d_graph_t>& glist, bool& done) const
void operator()(Graph& g, std::vector<d_graph_t>& glist, bool& done) const
{
if (glist.empty())
{
......@@ -62,7 +60,7 @@ void get_motifs(GraphInterface& g, size_t k, boost::python::list subgraph_list,
bool collect_vmaps, boost::python::list p, bool comp_iso,
bool fill_list, rng_t& rng)
{
vector<d_graph_t> list;
std::vector<d_graph_t> list;
for (int i = 0; i < boost::python::len(subgraph_list); ++i)
{
GraphInterface& sub =
......@@ -72,8 +70,8 @@ void get_motifs(GraphInterface& g, size_t k, boost::python::list subgraph_list,
std::ref(list)))();
}
vector<size_t> phist;
vector<double> plist;
std::vector<size_t> phist;
std::vector<double> plist;
double total = 1;
for (int i = 0; i < boost::python::len(p); ++i)
{
......@@ -90,7 +88,7 @@ void get_motifs(GraphInterface& g, size_t k, boost::python::list subgraph_list,
typedef property_map_type
::apply<int32_t, GraphInterface::vertex_index_map_t>::type
vmap_t;
vector<vector<vmap_t> > vmaps;
std::vector<std::vector<vmap_t> > vmaps;
run_action<>()
(g, std::bind(get_all_motifs(collect_vmaps, plist[0], comp_iso,
......@@ -104,7 +102,7 @@ void get_motifs(GraphInterface& g, size_t k, boost::python::list subgraph_list,
for (size_t i = 0; i < vmaps.size(); ++i)
{
boost::python::list vlist;
boost::python::list vlist;
for (size_t j = 0; j < vmaps[i].size(); ++j)
vlist.append(PythonPropertyMap<vmap_t>(vmaps[i][j]));
pvmaps.append(vlist);
......
......@@ -28,7 +28,7 @@
namespace graph_tool
{
using namespace boost;
namespace mpl = boost::mpl;
template <class Value>
void insert_sorted(std::vector<Value>& v, const Value& val)
......@@ -50,12 +50,12 @@ bool has_val(std::vector<Value>& v, const Value& val)
// gets all the subgraphs starting from vertex v and store it in subgraphs.
template <class Graph, class Sampler>
void get_subgraphs(Graph& g, typename graph_traits<Graph>::vertex_descriptor v,
void get_subgraphs(Graph& g, typename boost::graph_traits<Graph>::vertex_descriptor v,
size_t n,
std::vector<std::vector<typename graph_traits<Graph>::vertex_descriptor> >& subgraphs,
std::vector<std::vector<typename boost::graph_traits<Graph>::vertex_descriptor> >& subgraphs,
Sampler sampler)
{
typedef typename graph_traits<Graph>::vertex_descriptor vertex_t;
typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_t;
// extension and subgraph stack
std::vector<std::vector<vertex_t>> ext_stack(1);
......@@ -65,7 +65,7 @@ void get_subgraphs(Graph& g, typename graph_traits<Graph>::vertex_descriptor v,
sub_stack[0].push_back(v);
for (auto e : out_edges_range(v, g))
{
typename graph_traits<Graph>::vertex_descriptor u = target(e, g);
typename boost::graph_traits<Graph>::vertex_descriptor u = target(e, g);
if (u > v && !has_val(ext_stack[0], u))
{
insert_sorted(ext_stack[0], u);
......@@ -184,7 +184,7 @@ struct sample_some
{
j = i + random_v();
}
swap(extend[i], extend[j]);
std::swap(extend[i], extend[j]);
}
extend.resize(n);
}
......@@ -197,15 +197,15 @@ struct sample_some
// build the actual induced subgraph from the vertex list
template <class Graph, class GraphSG>
void make_subgraph
(std::vector<typename graph_traits<Graph>::vertex_descriptor>& vlist,
(std::vector<typename boost::graph_traits<Graph>::vertex_descriptor>& vlist,
Graph& g, GraphSG& sub)
{
for (size_t i = 0; i < vlist.size(); ++i)
add_vertex(sub);
for (size_t i = 0; i < vlist.size(); ++i)
{
typename graph_traits<Graph>::vertex_descriptor ov = vlist[i], ot;
typename graph_traits<GraphSG>::vertex_descriptor nv = vertex(i,sub);
typename boost::graph_traits<Graph>::vertex_descriptor ov = vlist[i], ot;
typename boost::graph_traits<GraphSG>::vertex_descriptor nv = vertex(i,sub);
for (auto e : out_edges_range(ov, g))
{
ot = target(e, g);
......@@ -225,24 +225,24 @@ bool graph_cmp(Graph& g1, Graph& g2)
if (num_vertices(g1) != num_vertices(g2) || num_edges(g1) != num_edges(g2))
return false;
typename graph_traits<Graph>::vertex_iterator v1, v1_end;
typename graph_traits<Graph>::vertex_iterator v2, v2_end;
tie(v2, v2_end) = vertices(g2);
for (tie(v1, v1_end) = vertices(g1); v1 != v1_end; ++v1)
typename boost::graph_traits<Graph>::vertex_iterator v1, v1_end;
typename boost::graph_traits<Graph>::vertex_iterator v2, v2_end;
std::tie(v2, v2_end) = vertices(g2);
for (std::tie(v1, v1_end) = vertices(g1); v1 != v1_end; ++v1)
{
if (out_degree(*v1, g1) != out_degree(*v2, g2))
return false;
if (in_degreeS()(*v1, g1) != in_degreeS()(*v2, g2))
return false;
std::vector<typename graph_traits<Graph>::vertex_descriptor> out1, out2;
typename graph_traits<Graph>::out_edge_iterator e, e_end;
for (tie(e, e_end) = out_edges(*v1, g1); e != e_end; ++e)
std::vector<typename boost::graph_traits<Graph>::vertex_descriptor> out1, out2;
typename boost::graph_traits<Graph>::out_edge_iterator e, e_end;
for (std::tie(e, e_end) = out_edges(*v1, g1); e != e_end; ++e)
out1.push_back(target(*e, g1));
for (tie(e, e_end) = out_edges(*v2, g2); e != e_end; ++e)
for (std::tie(e, e_end) = out_edges(*v2, g2); e != e_end; ++e)
out2.push_back(target(*e, g2));
sort(out1.begin(), out1.end());
sort(out2.begin(), out2.end());
std::sort(out1.begin(), out1.end());
std::sort(out2.begin(), out2.end());
if (out1 != out2)
return false;
}
......@@ -250,7 +250,7 @@ bool graph_cmp(Graph& g1, Graph& g2)
}
// short hand for subgraph types
typedef adj_list<size_t> d_graph_t;
typedef boost::adj_list<size_t> d_graph_t;
// we need this wrap to use the UndirectedAdaptor only on directed graphs
struct wrap_undirected
......@@ -259,7 +259,7 @@ struct wrap_undirected
struct apply
{
typedef typename mpl::if_<typename is_directed::apply<Graph>::type,
UndirectedAdaptor<Graph>,
boost::UndirectedAdaptor<Graph>,
Graph&>::type type;
};
};
......@@ -271,7 +271,7 @@ struct wrap_directed
{
typedef typename mpl::if_<typename is_directed::apply<Graph>::type,
Sub&,
UndirectedAdaptor<Sub>>::type type;
boost::UndirectedAdaptor<Sub>>::type type;
};
};
......@@ -314,7 +314,7 @@ struct get_all_motifs
{
// this hashes subgraphs according to their signature
gt_hash_map<std::vector<size_t>,
std::vector<pair<size_t, d_graph_t> >,
std::vector<std::pair<size_t, d_graph_t> >,
std::hash<std::vector<size_t>>> sub_list;
std::vector<size_t> sig; // current signature
......@@ -324,7 +324,7 @@ struct get_all_motifs
typename wrap_directed::apply<Graph,d_graph_t>::type
usub(sub);
get_sig(usub, sig);
sub_list[sig].push_back(make_pair(i, sub));
sub_list[sig].emplace_back(i, sub);
}
// the subgraph count
......@@ -352,7 +352,7 @@ struct get_all_motifs
auto random_v = std::bind(idist_t(0, V.size()-i-1),
std::ref(rng));
size_t j = i + random_v();
swap(V[i], V[j]);
std::swap(V[i], V[j]);
}
V.resize(n);
}
......@@ -362,9 +362,9 @@ struct get_all_motifs
private(sig)
for (size_t i = 0; i < N; ++i)
{
std::vector<std::vector<typename graph_traits<Graph>::vertex_descriptor> >
std::vector<std::vector<typename boost::graph_traits<Graph>::vertex_descriptor> >
subgraphs;
typename graph_traits<Graph>::vertex_descriptor v =
typename boost::graph_traits<Graph>::vertex_descriptor v =
(p < 1) ? V[i] : vertex(i, g);
if (!is_valid_vertex(v, g))
continue;
......@@ -403,8 +403,8 @@ struct get_all_motifs
if (comp_iso)
{
if (isomorphism(umotif, usub,
vertex_index1_map(get(vertex_index, umotif)).
vertex_index2_map(get(vertex_index, usub))))
vertex_index1_map(get(boost::vertex_index, umotif)).
vertex_index2_map(get(boost::vertex_index, usub))))
found = true;
}
else
......@@ -424,8 +424,8 @@ struct get_all_motifs
if (found == false && fill_list)
{
subgraph_list.push_back(sub);
sub_list[sig].push_back(make_pair(subgraph_list.size() - 1,
sub));
sub_list[sig].emplace_back(subgraph_list.size() - 1,
sub);
hist.push_back(1);
pos = hist.size() - 1;
found = true;
......
......@@ -33,6 +33,7 @@ namespace graph_tool
{
using namespace boost;
using namespace std;
// this will label each edge covariate in a consecutive range [0, C-1]
......
......@@ -37,7 +37,6 @@
namespace graph_tool
{
using namespace std;
// GraphInterface
// this class is the main interface to the internally kept graph. This is how
......@@ -112,17 +111,17 @@ public:
//
// python interface
//
boost::python::object degree_map(string deg, boost::any weight) const;
boost::python::object degree_map(std::string deg, boost::any weight) const;
// used for graph properties
boost::graph_property_tag get_descriptor() const { return boost::graph_property_tag(); }
bool check_valid() const {return true;}
// I/O
void write_to_file(string s, boost::python::object pf, string format,
void write_to_file(std::string s, boost::python::object pf, std::string format,
boost::python::list properties);
boost::python::tuple read_from_file(string s, boost::python::object pf,
string format,
boost::python::tuple read_from_file(std::string s, boost::python::object pf,
std::string format,
boost::python::list ignore_vp,
boost::python::list ignore_ep,
boost::python::list ignore_gp);
......@@ -151,7 +150,7 @@ public:
// Gets the encapsulated graph view. See graph_filtering.cc for details
boost::any get_graph_view() const;
vector<boost::any>& get_graph_views() {return _graph_views;}
std::vector<boost::any>& get_graph_views() {return _graph_views;}
private:
......@@ -160,7 +159,7 @@ private:
friend struct detail::graph_action;
// this is the main graph
shared_ptr<multigraph_t> _mg;
std::shared_ptr<multigraph_t> _mg;
// vertex index map
vertex_index_map_t _vertex_index;
......@@ -169,7 +168,7 @@ private:
edge_index_map_t _edge_index;
// this will hold an instance of the graph views at run time
vector<boost::any> _graph_views;
std::vector<boost::any> _graph_views;
// reverse and directed states
bool _reversed;
......
......@@ -27,29 +27,28 @@
// things go wrong
namespace graph_tool{
using namespace std;
class GraphException : public std::exception
{
public:
GraphException(const string& error);
GraphException(const std::string& error);
virtual ~GraphException() throw ();
virtual const char * what () const throw ();
protected:
string _error;
std::string _error;
};
class IOException : public GraphException
{
public:
IOException(const string& error);
IOException(const std::string& error);
virtual ~IOException() throw ();
};
class ValueException : public GraphException
{
public:
ValueException(const string& error);
ValueException(const std::string& error);
virtual ~ValueException() throw ();
};
......
......@@ -21,6 +21,7 @@
using namespace graph_tool;
using namespace graph_tool::detail;
using namespace boost;
using namespace std;
bool graph_tool::graph_filtering_enabled()
{
......
......@@ -111,11 +111,11 @@ class ActionNotFound: public GraphException
{
public:
ActionNotFound(const std::type_info& action,
const vector<const std::type_info*>& args);
const std::vector<const std::type_info*>& args);
virtual ~ActionNotFound() throw () {}
private:
const std::type_info& _action;
vector<const std::type_info*> _args;
std::vector<const std::type_info*> _args;
};
namespace detail
......@@ -196,10 +196,10 @@ struct graph_filter
// type. Otherwise return the filtered_graph type.
typedef typename boost::mpl::if_<
typename boost::mpl::and_<
is_same<edge_predicate,
boost::keep_all>,
is_same<vertex_predicate,
boost::keep_all>
std::is_same<edge_predicate,
boost::keep_all>,
std::is_same<vertex_predicate,
boost::keep_all>
>::type,
Graph,
filtered_graph_t>::type type;
......@@ -450,7 +450,7 @@ struct action_dispatch
boost::mpl::nested_for_each<TRS...>(_a, std::forward<Args>(args)...);
if (!found)
{
vector<const std::type_info*> args_t = {(&(args).type())...};
std::vector<const std::type_info*> args_t = {(&(args).type())...};
throw ActionNotFound(typeid(Action), args_t);
}
}
......
......@@ -50,7 +50,6 @@
namespace graph_tool
{
using namespace std;
// Metaprogramming
// ===============
......@@ -64,11 +63,12 @@ using namespace std;
// broken, and use a vector<uint8_t> instead!
// see: http://www.gotw.ca/publications/N1211.pdf
typedef boost::mpl::vector15<uint8_t, int16_t, int32_t, int64_t, double, long double, string,
vector<uint8_t>, vector<int16_t>, vector<int32_t>, vector<int64_t>,
vector<double>, vector<long double>, vector<string>,
boost::python::object>
value_types;
typedef boost::mpl::vector15<uint8_t, int16_t, int32_t, int64_t, double,
long double, std::string, std::vector<uint8_t>,
std::vector<int16_t>, std::vector<int32_t>,
std::vector<int64_t>, std::vector<double>,
std::vector<long double>, std::vector<std::string>,
boost::python::object> value_types;
extern const char* type_names[]; // respective type names (defined in
// graph_properties.cc)
......@@ -85,7 +85,7 @@ typedef boost::mpl::vector2<double, long double> floating_types;
struct make_vector
{
template <class ValueType> struct apply { typedef vector<ValueType> type; };
template <class ValueType> struct apply { typedef std::vector<ValueType> type; };
};
// scalar_vector_types: vector types with floating point values
......@@ -195,21 +195,21 @@ public:
if (_all_names.empty())
{
boost::mpl::for_each<TypeSequence>
(bind(get_all_names(), std::placeholders::_1,
ref(_type_names), ref(_all_names)));
(std::bind(get_all_names(), std::placeholders::_1,
std::ref(_type_names), std::ref(_all_names)));
}
}
const string& operator()(const std::type_info& type) const
const std::string& operator()(const std::type_info& type) const
{
string const* name;
std::string const* name;
boost::mpl::for_each<TypeSequence>
(bind(find_name(), std::placeholders::_1, ref(type),
ref(_all_names), ref(name)));
(std::bind(find_name(), std::placeholders::_1, std::ref(type),
std::ref(_all_names), std::ref(name)));
return *name;
}
const vector<string>& all_names() const
const std::vector<std::string>& all_names() const
{
return _all_names;
}
......@@ -219,8 +219,8 @@ private:
{
template <class Type>
void operator()(Type, const std::type_info& type,
const vector<string>& all_names,
string const*& name) const
const std::vector<std::string>& all_names,
std::string const*& name) const
{
size_t index = boost::mpl::find<TypeSequence,Type>::type::pos::value;
if (type == typeid(Type))
......@@ -233,7 +233,7 @@ private:
typedef void result_type;
template <class Type>
void operator()(Type, const char** t_names,
vector<string>& names) const
std::vector<std::string>& names) const
{
size_t index = boost::mpl::find<NamedSequence,Type>::type::pos::value;
names.push_back(t_names[index]);
......@@ -241,7 +241,7 @@ private:
};
const char** _type_names;
vector<string> _all_names;
std::vector<std::string> _all_names;
};
//
......@@ -257,7 +257,7 @@ struct convert
{
Type1 operator()(const Type2& v) const
{
return do_convert(v, is_convertible<Type2,Type1>());
return do_convert(v, std::is_convertible<Type2,Type1>());
}
Type1 do_convert(const Type2& v, std::true_type) const
......@@ -295,14 +295,14 @@ struct convert
}
};
// string
// std::string
template <class T1>
struct specific_convert<T1,string>
struct specific_convert<T1,std::string>
{
T1 operator()(const string& v) const
T1 operator()(const std::string& v) const
{
//uint8_t is not char, it is bool!
if (is_same<T1, uint8_t>::value)
if (std::is_same<T1, uint8_t>::value)
return convert<T1,int>()(boost::lexical_cast<int>(v));
else
return boost::lexical_cast<T1>(v);
......@@ -310,25 +310,25 @@ struct convert
};
template <class T2>
struct specific_convert<string,T2>
struct specific_convert<std::string,T2>
{
string operator()(const T2& v) const
std::string operator()(const T2& v) const
{
//uint8_t is not char, it is bool!
if (is_same<T2, uint8_t>::value)
return boost::lexical_cast<string>(convert<int,T2>()(v));
if (std::is_same<T2, uint8_t>::value)
return boost::lexical_cast<std::string>(convert<int,T2>()(v));
else
return boost::lexical_cast<string>(v);
return boost::lexical_cast<std::string>(v);
}
};
// vectors
template <class T1, class T2>
struct specific_convert<vector<T1>, vector<T2>>
struct specific_convert<std::vector<T1>, std::vector<T2>>
{
vector<T1> operator()(const vector<T2>& v) const
std::vector<T1> operator()(const std::vector<T2>& v) const
{
vector<T1> v2(v.size());
std::vector<T1> v2(v.size());
convert<T1,T2> c;
for (size_t i = 0; i < v.size(); ++i)
v2[i] = c(v[i]);
......@@ -338,13 +338,13 @@ struct convert
};
// python::object to string, to solve ambiguity
// python::object to std::string, to solve ambiguity
template<> template<>
struct convert<string,boost::python::object>::specific_convert<string,boost::python::object>
struct convert<std::string,boost::python::object>::specific_convert<std::string,boost::python::object>
{
string operator()(const boost::python::object& v) const
std::string operator()(const boost::python::object& v) const
{
boost::python::extract<string> x(v);
boost::python::extract<std::string> x(v);
if (x.check())
return x();
else
......@@ -387,7 +387,7 @@ public:
if (converter == 0)
throw boost::bad_lexical_cast();
else
_converter = shared_ptr<ValueConverter>(converter);
_converter = std::shared_ptr<ValueConverter>(converter);
}
DynamicPropertyMapWrap() {}
......@@ -423,15 +423,15 @@ private:
virtual Value get(const Key& k)
{
return get_dispatch(_pmap, k,
is_convertible<typename boost::property_traits<PropertyMap>::category,
boost::readable_property_map_tag>());
std::is_convertible<typename boost::property_traits<PropertyMap>::category,
boost::readable_property_map_tag>());
}