Commit 1c796549 authored by Tiago Peixoto's avatar Tiago Peixoto

Fix bug in eigenvector(), pagerank() and eigentrust() with undirected graphs

parent 08a4a117
......@@ -42,7 +42,7 @@ struct get_eigentrust
// Norm c values
InferredTrustMap c_sum(vertex_index);
if (typename is_directed::apply<Graph>::type())
if (is_directed::apply<Graph>::type::value)
{
TrustMap c_temp(edge_index, c.get_storage().size());
......@@ -120,7 +120,7 @@ struct get_eigentrust
{
typename graph_traits<Graph>::vertex_descriptor s =
source(*e,g);
if (!typename is_directed::apply<Graph>::type())
if (!is_directed::apply<Graph>::type::value)
t_temp[v] += get(c, *e)*t[s]/abs(c_sum[s]);
else
t_temp[v] += get(c, *e)*t[s];
......
......@@ -72,12 +72,15 @@ struct get_eigenvector
continue;
c_temp[v] = 0;
typename in_edge_iteratorS<Graph>::type e, e_end;
for (tie(e, e_end) = in_edge_iteratorS<Graph>::get_edges(v, g);
typename in_or_out_edge_iteratorS<Graph>::type e, e_end;
for (tie(e, e_end) = in_or_out_edge_iteratorS<Graph>::get_edges(v, g);
e != e_end; ++e)
{
typename graph_traits<Graph>::vertex_descriptor s =
source(*e,g);
typename graph_traits<Graph>::vertex_descriptor s;
if (is_directed::apply<Graph>::type::value)
s = source(*e,g);
else
s = target(*e,g);
c_temp[v] += get(w, *e) * c[s];
}
norm += power(c_temp[v], 2);
......
......@@ -73,12 +73,15 @@ struct get_pagerank
continue;
rank_type r = 0;
typename in_edge_iteratorS<Graph>::type e, e_end;
for (tie(e, e_end) = in_edge_iteratorS<Graph>::get_edges(v, g);
typename in_or_out_edge_iteratorS<Graph>::type e, e_end;
for (tie(e, e_end) = in_or_out_edge_iteratorS<Graph>::get_edges(v, g);
e != e_end; ++e)
{
typename graph_traits<Graph>::vertex_descriptor s =
source(*e, g);
typename graph_traits<Graph>::vertex_descriptor s;
if (is_directed::apply<Graph>::type::value)
s = source(*e, g);
else
s = target(*e, g);
r += (get(rank, s) * get(weight, *e)) / get(deg, s);
}
......
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