Commit 70a2ce29 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Fix some compilation issues and warnings with clang

parent b2b27965
......@@ -51,14 +51,14 @@ namespace detail { namespace graph {
typedef typename graph_traits<Graph>::vertex_descriptor vertex_descriptor;
typedef typename graph_traits<Graph>::edge_descriptor edge_descriptor;
brandes_dijkstra_visitor(std::stack<vertex_descriptor>& ordered_vertices,
WeightMap weight,
IncomingMap incoming,
DistanceMap distance,
PathCountMap path_count)
: ordered_vertices(ordered_vertices), weight(weight),
incoming(incoming), distance(distance),
path_count(path_count)
brandes_dijkstra_visitor(std::stack<vertex_descriptor>& iordered_vertices,
WeightMap iweight,
IncomingMap iincoming,
DistanceMap idistance,
PathCountMap ipath_count)
: ordered_vertices(iordered_vertices), weight(iweight),
incoming(iincoming), distance(idistance),
path_count(ipath_count)
{ }
/**
......@@ -117,8 +117,8 @@ namespace detail { namespace graph {
template<typename WeightMap>
struct brandes_dijkstra_shortest_paths
{
brandes_dijkstra_shortest_paths(WeightMap weight_map)
: weight_map(weight_map) { }
brandes_dijkstra_shortest_paths(WeightMap iweight_map)
: weight_map(iweight_map) { }
template<typename Graph, typename IncomingMap, typename DistanceMap,
typename PathCountMap, typename VertexIndexMap>
......@@ -165,11 +165,11 @@ namespace detail { namespace graph {
typedef typename graph_traits<Graph>::vertex_descriptor
vertex_descriptor;
visitor_type(IncomingMap incoming, DistanceMap distance,
PathCountMap path_count,
std::stack<vertex_descriptor>& ordered_vertices)
: incoming(incoming), distance(distance),
path_count(path_count), ordered_vertices(ordered_vertices) { }
visitor_type(IncomingMap iincoming, DistanceMap idistance,
PathCountMap ipath_count,
std::stack<vertex_descriptor>& iordered_vertices)
: incoming(iincoming), distance(idistance),
path_count(ipath_count), ordered_vertices(iordered_vertices) { }
/// Keep track of vertices as they are reached
void examine_vertex(vertex_descriptor v, Graph&)
......@@ -344,7 +344,7 @@ namespace detail { namespace graph {
while (!ordered_vertices.empty())
{
vertex_descriptor w = ordered_vertices.top();
vertex_descriptor u = ordered_vertices.top();
ordered_vertices.pop();
typedef typename property_traits<IncomingMap>::value_type
......@@ -353,18 +353,18 @@ namespace detail { namespace graph {
typedef typename property_traits<DependencyMap>::value_type
dependency_type;
for (incoming_iterator vw = incoming[w].begin();
vw != incoming[w].end(); ++vw) {
for (incoming_iterator vw = incoming[u].begin();
vw != incoming[u].end(); ++vw) {
vertex_descriptor v = source(*vw, g);
dependency_type factor = dependency_type(get(path_count, v))
/ dependency_type(get(path_count, w));
factor *= (dependency_type(1) + get(dependency, w));
/ dependency_type(get(path_count, u));
factor *= (dependency_type(1) + get(dependency, u));
put(dependency, v, get(dependency, v) + factor);
update_centrality(edge_centrality_map, *vw, factor);
}
if (w != s) {
update_centrality(centrality, w, get(dependency, w));
if (u != s) {
update_centrality(centrality, u, get(dependency, u));
}
}
......
......@@ -85,8 +85,8 @@ namespace boost {
friend struct compare_multiplicity;
struct compare_multiplicity
{
compare_multiplicity(Invariant1 invariant1, size_type* multiplicity)
: invariant1(invariant1), multiplicity(multiplicity) { }
compare_multiplicity(Invariant1 inv1, size_type* mult)
: invariant1(inv1), multiplicity(mult) { }
bool operator()(const vertex1_t& x, const vertex1_t& y) const {
return multiplicity[invariant1(x)] < multiplicity[invariant1(y)];
}
......@@ -102,7 +102,7 @@ namespace boost {
void discover_vertex(vertex1_t v, const Graph1&) const {
vertices.push_back(v);
}
void examine_edge(edge1_t e, const Graph1& G1) const {
void examine_edge(edge1_t e, const Graph1&) const {
edges.push_back(e);
}
std::vector<vertex1_t>& vertices;
......@@ -110,8 +110,8 @@ namespace boost {
};
struct edge_cmp {
edge_cmp(const Graph1& G1, DFSNumMap dfs_num)
: G1(G1), dfs_num(dfs_num) { }
edge_cmp(const Graph1& Gr1, DFSNumMap dfs_n)
: G1(Gr1), dfs_num(dfs_n) { }
bool operator()(const edge1_t& e1, const edge1_t& e2) const {
using namespace std;
int u1 = dfs_num[source(e1,G1)], v1 = dfs_num[target(e1,G1)];
......@@ -127,12 +127,12 @@ namespace boost {
};
public:
isomorphism_algo(const Graph1& G1, const Graph2& G2, IsoMapping f,
Invariant1 invariant1, Invariant2 invariant2, std::size_t max_invariant,
IndexMap1 index_map1, IndexMap2 index_map2)
: G1(G1), G2(G2), f(f), invariant1(invariant1), invariant2(invariant2),
max_invariant(max_invariant),
index_map1(index_map1), index_map2(index_map2)
isomorphism_algo(const Graph1& GG1, const Graph2& GG2, IsoMapping mf,
Invariant1 inv1, Invariant2 inv2, std::size_t max_inv,
IndexMap1 index1, IndexMap2 index2)
: G1(GG1), G2(GG2), f(mf), invariant1(inv1), invariant2(inv2),
max_invariant(max_inv),
index_map1(index1), index_map2(index2)
{
in_S_vec.resize(num_vertices(G1));
in_S = make_safe_iterator_property_map
......@@ -236,8 +236,8 @@ namespace boost {
count_if(adjacent_vertices(f[k], G2), make_indirect_pmap(in_S));
for (int jj = 0; jj < dfs_num_k; ++jj) {
vertex1_t j = dfs_vertices[jj];
num_edges_on_k -= count(adjacent_vertices(f[j], G2), f[k]);
vertex1_t vj = dfs_vertices[jj];
num_edges_on_k -= count(adjacent_vertices(f[vj], G2), f[k]);
}
if (num_edges_on_k != 0)
......
......@@ -19,6 +19,7 @@ libgraph_tool_core_LTLIBRARIES = libgraph_tool_core.la
libgraph_tool_core_la_SOURCES = \
graph.cc \
graph_exceptions.cc \
graph_bind.cc \
graph_copy.cc \
graph_filtering.cc \
......
......@@ -162,7 +162,7 @@ struct get_central_point_dominance
void operator()(Graph& g, VertexBetweenness vertex_betweenness, double& c)
const
{
c = central_point_dominance(g, vertex_betweenness);
c = double(central_point_dominance(g, vertex_betweenness));
}
};
......
......@@ -104,7 +104,6 @@ struct get_eigentrust
while (delta >= epslon)
{
delta = 0;
int i, N = num_vertices(g);
#pragma omp parallel for default(shared) private(i) \
schedule(dynamic) reduction(+:delta)
for (i = 0; i < N; ++i)
......@@ -139,7 +138,7 @@ struct get_eigentrust
{
#pragma omp parallel for default(shared) private(i) \
schedule(dynamic)
for (int i = 0; i < N; ++i)
for (i = 0; i < N; ++i)
{
typename graph_traits<Graph>::vertex_descriptor v =
vertex(i, g);
......
......@@ -46,8 +46,7 @@ long double eigenvector(GraphInterface& g, boost::any w, boost::any c,
long double eig = 0;
run_action<>()
(g, bind<void>
(get_eigenvector(),
_1, g.GetVertexIndex(), g.GetEdgeIndex(), _2,
(get_eigenvector(), _1, g.GetEdgeIndex(), _2,
_3, epsilon, max_iter, ref(eig)),
weight_props_t(),
vertex_floating_properties())(w, c);
......
......@@ -32,11 +32,11 @@ using namespace boost;
struct get_eigenvector
{
template <class Graph, class VertexIndex, class EdgeIndex, class WeightMap,
template <class Graph, class VertexIndex, class WeightMap,
class CentralityMap>
void operator()(Graph& g, VertexIndex vertex_index,
EdgeIndex edge_index, WeightMap w, CentralityMap c,
double epsilon, size_t max_iter, long double& eig) const
void operator()(Graph& g, VertexIndex vertex_index, WeightMap w,
CentralityMap c, double epsilon, size_t max_iter,
long double& eig) const
{
typedef typename property_traits<WeightMap>::value_type c_type;
typedef typename property_traits<CentralityMap>::value_type t_type;
......@@ -57,13 +57,11 @@ struct get_eigenvector
t_type norm = 0;
t_type delta = epsilon + 1;
size_t iter = 0;
while (delta >= epsilon)
{
norm = 0;
int i, N = num_vertices(g);
#pragma omp parallel for default(shared) private(i) \
schedule(dynamic) reduction(+:norm)
for (i = 0; i < N; ++i)
......@@ -109,7 +107,7 @@ struct get_eigenvector
{
#pragma omp parallel for default(shared) private(i) \
schedule(dynamic)
for (int i = 0; i < N; ++i)
for (i = 0; i < N; ++i)
{
typename graph_traits<Graph>::vertex_descriptor v =
vertex(i, g);
......
......@@ -63,7 +63,6 @@ struct get_pagerank
while (delta >= epsilon)
{
delta = 0;
int i, N = num_vertices(g);
#pragma omp parallel for default(shared) private(i) \
schedule(dynamic) reduction(+:delta)
for (i = 0; i < N; ++i)
......@@ -97,7 +96,7 @@ struct get_pagerank
{
#pragma omp parallel for default(shared) private(i) \
schedule(dynamic)
for (int i = 0; i < N; ++i)
for (i = 0; i < N; ++i)
{
typename graph_traits<Graph>::vertex_descriptor v =
vertex(i, g);
......
......@@ -38,8 +38,7 @@ void trust_transitivity(GraphInterface& g, int64_t source, int64_t target,
run_action<>()(g,
bind<void>(get_trust_transitivity(), _1, g.GetVertexIndex(),
g.GetEdgeIndex(), g.GetMaxEdgeIndex(), source,
target, _2, _3),
source, target, _2, _3),
edge_floating_properties(),
vertex_floating_vector_properties())(c,t);
}
......
......@@ -47,7 +47,7 @@ public:
template <class Graph>
void examine_vertex(typename graph_traits<Graph>::vertex_descriptor u,
Graph& g)
Graph&)
{
// stop if all sources are found
if (_source_map[u])
......@@ -78,7 +78,7 @@ struct dist_combine
template <class DistType, class WeightType>
DistType operator()(const DistType& d, const WeightType& w) const
{
return d*w;
return DistType(d * w);
}
};
......@@ -94,12 +94,10 @@ struct filter_vertex_pred
struct get_trust_transitivity
{
template <class Graph, class VertexIndex, class EdgeIndex, class TrustMap,
template <class Graph, class VertexIndex, class TrustMap,
class InferredTrustMap>
void operator()(Graph& g, VertexIndex vertex_index, EdgeIndex edge_index,
size_t max_edge_index, int64_t source, int64_t target,
TrustMap c, InferredTrustMap t)
const
void operator()(Graph& g, VertexIndex vertex_index, int64_t source,
int64_t target, TrustMap c, InferredTrustMap t) const
{
typedef typename graph_traits<Graph>::vertex_descriptor vertex_t;
typedef typename graph_traits<Graph>::edge_descriptor edge_t;
......
......@@ -142,6 +142,7 @@ struct set_clustering_to_property
template <class Graph, class ClustMap>
void operator()(const Graph& g, ClustMap clust_map) const
{
typedef typename property_traits<ClustMap>::value_type c_type;
typename get_undirected_graph<Graph>::type ug(g);
int i, N = num_vertices(g);
......@@ -159,7 +160,7 @@ struct set_clustering_to_property
#pragma omp critical
{
clust_map[v] = clustering;
clust_map[v] = c_type(clustering);
}
}
}
......
......@@ -32,7 +32,7 @@ using namespace graph_tool;
struct null_copy
{
template <class T1, class T2>
void operator()(const T1& t1, const T2& t2) const {}
void operator()(const T1&, const T2&) const {}
};
struct append_to_list
......
......@@ -172,9 +172,9 @@ struct sample_some
r = random();
}
if (r < u)
n = ceil(nc*pd);
n = size_t(ceil(nc*pd));
else
n = floor(nc*pd);
n = size_t(floor(nc*pd));
if (n == extend.size())
return;
......@@ -339,9 +339,9 @@ struct get_all_motifs
size_t n;
if (random() < p)
n = ceil(V.size()*p);
n = size_t(ceil(V.size()*p));
else
n = floor(V.size()*p);
n = size_t(floor(V.size()*p));
typedef tr1::uniform_int<size_t> idist_t;
for (size_t i = 0; i < n; ++i)
......
......@@ -33,9 +33,8 @@ using namespace graph_tool;
void community_structure(GraphInterface& g, double gamma, string corr_name,
size_t n_iter, double Tmin, double Tmax, size_t Nspins,
bool new_spins, size_t seed, bool verbose,
string history_file, boost::any weight,
boost::any property)
size_t seed, bool verbose, string history_file,
boost::any weight, boost::any property)
{
typedef property_map_types::apply<mpl::vector<int32_t,int64_t>,
GraphInterface::vertex_index_map_t,
......
......@@ -90,11 +90,11 @@ struct get_communities
// init spins from [0,N-1] and global info
tr1::uniform_int<size_t> sample_spin(0, n_spins-1);
typename graph_traits<Graph>::vertex_iterator v,v_end;
for (tie(v,v_end) = vertices(g); v != v_end; ++v)
typename graph_traits<Graph>::vertex_iterator vi,vi_end;
for (tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi)
{
s[*v] = temp_s[*v] = sample_spin(rng);
Ns[s[*v]]++;
s[*vi] = temp_s[*vi] = sample_spin(rng);
Ns[s[*vi]]++;
}
NNKS<Graph,CommunityMap> Nnnks(g, s); // this will retrieve the expected
......@@ -233,11 +233,11 @@ struct get_communities
// rename spins, starting from zero
unordered_map<size_t,size_t> spins;
for (tie(v,v_end) = vertices(g); v != v_end; ++v)
for (tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi)
{
if (spins.find(s[*v]) == spins.end())
spins[s[*v]] = spins.size() - 1;
s[*v] = spins[s[*v]];
if (spins.find(s[*vi]) == spins.end())
spins[s[*vi]] = spins.size() - 1;
s[*vi] = spins[s[*vi]];
}
}
......@@ -262,7 +262,7 @@ public:
_p = _avg_k/(N*N);
}
void Update(size_t k, size_t old_s, size_t s)
void Update(size_t, size_t old_s, size_t s)
{
_Ns[old_s]--;
if (_Ns[old_s] == 0)
......@@ -270,7 +270,7 @@ public:
_Ns[s]++;
}
double operator()(size_t k, size_t s) const
double operator()(size_t, size_t s) const
{
size_t ns = 0;
typeof(_Ns.begin()) iter = _Ns.find(s);
......@@ -343,14 +343,14 @@ public:
typename graph_traits<Graph>::edge_iterator e,e_end;
for (tie(e,e_end) = edges(_g); e != e_end; ++e)
{
typename graph_traits<Graph>::vertex_descriptor s, t;
typename graph_traits<Graph>::vertex_descriptor src, tgt;
s = source(*e,g);
t = target(*e,g);
if (s != t)
src = source(*e,g);
tgt = target(*e,g);
if (src != tgt)
{
size_t k1 = out_degree_no_loops(s, g);
size_t k2 = out_degree_no_loops(t, g);
size_t k1 = out_degree_no_loops(src, g);
size_t k2 = out_degree_no_loops(tgt, g);
_Pkk[k1][k2]++;
_Pkk[k2][k1]++;
E++;
......
......@@ -50,7 +50,7 @@ struct get_community_network_dispatch
class VertexWeightMap, class EdgeWeightMap, class EdgeIndex,
class VertexIndex>
void operator()(const Graph& g, CommunityGraph& cg,
VertexIndex cvertex_index, EdgeIndex cedge_index,
VertexIndex, EdgeIndex cedge_index,
CommunityMap s_map, boost::any acs_map,
VertexWeightMap vweight, EdgeWeightMap eweight,
pair<boost::any,boost::any> count) const
......@@ -67,7 +67,7 @@ struct get_community_network_dispatch
vweight_t vertex_count = boost::any_cast<vweight_t>(count.first);
eweight_t edge_count = boost::any_cast<eweight_t>(count.second);
get_community_network()(g, cg, cvertex_index, cedge_index, s_map,
get_community_network()(g, cg, cedge_index, s_map,
cs_map, vweight, eweight, vertex_count,
edge_count, _self_loops);
}
......
......@@ -37,11 +37,9 @@ using namespace boost;
struct get_community_network
{
template <class Graph, class CommunityGraph, class CommunityMap,
class CCommunityMap,
class VertexWeightMap, class EdgeWeightMap, class EdgeIndex,
class VertexIndex, class VertexProperty, class EdgeProperty>
void operator()(const Graph& g, CommunityGraph& cg,
VertexIndex cvertex_index, EdgeIndex cedge_index,
class CCommunityMap, class VertexWeightMap, class EdgeWeightMap,
class EdgeIndex, class VertexProperty, class EdgeProperty>
void operator()(const Graph& g, CommunityGraph& cg, EdgeIndex cedge_index,
CommunityMap s_map, CCommunityMap cs_map,
VertexWeightMap vweight, EdgeWeightMap eweight,
VertexProperty vertex_count, EdgeProperty edge_count,
......@@ -60,12 +58,12 @@ struct get_community_network
tr1::unordered_map<s_type, pair<vector<vertex_t>, vprop_type>, hash<s_type> >
comms;
typename graph_traits<Graph>::vertex_iterator v, v_end;
for (tie(v, v_end) = vertices(g); v != v_end; ++v)
typename graph_traits<Graph>::vertex_iterator vi, vi_end;
for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
{
pair<vector<vertex_t>, vprop_type>& m = comms[get(s_map, *v)];
m.first.push_back(*v);
m.second += get(vweight, *v);
pair<vector<vertex_t>, vprop_type>& m = comms[get(s_map, *vi)];
m.first.push_back(*vi);
m.second += get(vweight, *vi);
}
// create vertices
......@@ -123,16 +121,16 @@ struct get_community_network
void put_dispatch(PropertyMap cs_map,
const typename property_traits<PropertyMap>::key_type& v,
const typename property_traits<PropertyMap>::value_type& val,
mpl::true_ is_writable) const
mpl::true_ /*is_writable*/) const
{
put(cs_map, v, val);
}
template <class PropertyMap>
void put_dispatch(PropertyMap cs_map,
const typename property_traits<PropertyMap>::key_type& v,
const typename property_traits<PropertyMap>::value_type& val,
mpl::false_ is_writable) const
void put_dispatch(PropertyMap,
const typename property_traits<PropertyMap>::key_type&,
const typename property_traits<PropertyMap>::value_type&,
mpl::false_ /*is_writable*/) const
{
}
......
......@@ -58,11 +58,11 @@ struct get_assortativity_coefficient
if (v == graph_traits<Graph>::null_vertex())
continue;
double k1 = deg(v, g);
double k1 = double(deg(v, g));
typename graph_traits<Graph>::out_edge_iterator e, e_end;
for (tie(e,e_end) = out_edges(v, g); e != e_end; ++e)
{
double k2 = deg(target(*e, g), g);
double k2 = double(deg(target(*e, g), g));
if (k1 == k2)
e_kk += c;
sa[k1] += c;
......@@ -93,11 +93,11 @@ struct get_assortativity_coefficient
if (v == graph_traits<Graph>::null_vertex())
continue;
double k1 = deg(v, g);
double k1 = double(deg(v, g));
typename graph_traits<Graph>::out_edge_iterator e, e_end;
for (tie(e,e_end) = out_edges(v, g); e != e_end; ++e)
{
double k2 = deg(target(*e,g),g);
double k2 = double(deg(target(*e,g),g));
double tl2 = (t2*(n_edges*n_edges) - b[k1] - a[k2])/
((n_edges-1)*(n_edges-1));
double tl1 = t1*n_edges;
......@@ -137,11 +137,11 @@ struct get_scalar_assortativity_coefficient
if (v == graph_traits<Graph>::null_vertex())
continue;
double k1 = deg(v, g);
double k1 = double(deg(v, g));
typename graph_traits<Graph>::out_edge_iterator e, e_end;
for (tie(e,e_end) = out_edges(v, g); e != e_end; ++e)
{
double k2 = deg(target(*e,g),g);
double k2 = double(deg(target(*e,g),g));
a += k1*c;
da += k1*k1*c;
b += k2*c;
......@@ -174,14 +174,14 @@ struct get_scalar_assortativity_coefficient
if (v == graph_traits<Graph>::null_vertex())
continue;
double k1 = deg(v, g);
double k1 = double(deg(v, g));
double al = (a*n_edges - k1)/(n_edges-1);
double dal = sqrt((da - k1*k1)/(n_edges-1) - al*al);
typename graph_traits<Graph>::out_edge_iterator e, e_end;
for (tie(e,e_end) = out_edges(v, g); e != e_end; ++e)
{
double k2 = deg(target(*e, g), g);
double k2 = double(deg(target(*e, g), g));
double bl = (b*n_edges - k2)/(n_edges-1);
double dbl = sqrt((db - k2*k2)/(n_edges-1) - bl*bl);
double t1l = (e_xy - k1*k2)/(n_edges-1);
......
......@@ -79,7 +79,7 @@ struct get_avg_correlation
s_sum2.Gather();
s_count.Gather();
for (size_t i = 0; i < sum.GetArray().size(); ++i)
for (i = 0; i < int(sum.GetArray().size()); ++i)
{
sum.GetArray()[i] /= count.GetArray()[i];
sum2.GetArray()[i] =
......
......@@ -44,7 +44,8 @@ public:
Hist& hist)
{
typename Hist::point_t k;
k[0] = deg1(v, g);