Boost logo

Boost Users :

Subject: Re: [Boost-users] [graph] problem with weight_map ? (brandes_betweenness_centrality)
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2013-03-19 10:11:59


On Tue, 19 Mar 2013, The Maschine wrote:

> Hi all,
> I think I've got a problem with the way I use the weight property map in my betweenness_centrality (and maybe other locations too).
>
> I've got a graph like that:
>
> typedef boost::property<boost::edge_weight_t, double> EdgeWeightProperty;
>
> typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, VertexProperties, EdgeWeightProperty> unGraph;
>
> And I add edges with weights like that (simplified):
>
> EdgeWeightProperty weight = getWeight(a, b); // 0f ... 2.0f

Can you just assign a double to a boost::property<...> object? That
should probably not be allowed.

> std::pair<unGraph::edge_descriptor, bool> e = boost::add_edge(a, b, weight, m_ugraph);
>
>
>
> Than I try to do the brandes_centrality_betweenness:
> std::vector< double > v_centrality_vec(boost::num_vertices(m_ugraph), 0.0);
>
>
>
> boost::brandes_betweenness_centrality(m_ugraph , boost::centrality_map(boost::make_iterator_property_map(v_centrality_vec.begin(),boost::get(boost::vertex_index, m_ug
> raph),double())).vertex_index_map(get(boost::vertex_index, m_ugraph)).weight_map(get(boost::edge_weight, m_ugraph)) );
>
>
>
> But I get crazy results...
> 1) I have checked by hand that my "getWeight" (my weights) are OK.
> 2) I have set _ALL_ weights to 1.0 (almost as if brandes was using BFS internally), Again I get the _SAME_ crazy results!

What happens if you write an explicit loop over all of the edges and use
put(edge_weight, g, e) directly? Does that change any of the results?

-- Jeremiah Willcock


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net