Boost logo

Boost Users :

Subject: Re: [Boost-users] [graph] problem with weight_map ? (brandes_betweenness_centrality)
From: The Maschine (justthemaschine_at_[hidden])
Date: 2013-03-19 08:56:40


My newline character got crazy..
Sorry.
I separate some line below for easier reading.

typedef boost::property<boost::edge_weight_t, double> EdgeWeightProperty;
>
>
###

typedef boost::adjacency_list<boost::vecS, boost::vecS,
boost::undirectedS, VertexProperties, EdgeWeightProperty> unGraph;
>
> ###

>
> EdgeWeightProperty weight = getWeight(a, b); // 0f ... 2.0f
>
> ###

std::pair<unGraph::edge_descriptor, bool> e = boost::add_edge(a, b,
weight, m_ugraph);
>
> ###

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_ugraph),double())).vertex_index_map(get(boost::vertex_index, m_ugraph)).weight_map(get(boost::edge_weight, m_ugraph)) );
>
>
On Tue, Mar 19, 2013 at 12:52 PM, The Maschine <
justthemaschine_at_[hidden]> 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
>
>

> 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_ugraph),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!
>
>
> So there is something wrong with the way Im using the weight_map.
>
>
> What am I missing??
>
>
> Best,
>
> Tasos
>
>
>
>



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