Hi everyone, this is from Jason. I am a new user of Boost library. Nowadays, I am doing a research about betweenness centrality measure. I am very confused about how to use boost to calculate the betweenness centrality. I need to calculate the centrality score based on a undirected and weighted graph. The following code is what I tried to do. But this block of code can only be used for calculated for unweighted graph. Could anyone here can offer me examples? Thanks for any reply.

#include <boost/graph/betweenness_centrality.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graphviz.hpp>
 
typedef boost::property<boost::edge_weight_t, float> EdgeWeightProperty;
typedef boost::adjacency_list < boost::listS, boost::vecS, boost::undirectedS,
    boost::no_property, EdgeWeightProperty > Graph;
typedef boost::graph_traits < Graph >::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits < Graph >::edge_descriptor edge_descriptor;
typedef std::pair<int, int> Edge;
typedef std::map<Edge, int> StdEdgeIndexMap;
 
void betweennessCentrality()
{
  Graph g;
  Graph::vertex_descriptor a1 = boost::add_vertex(g);
  Graph::vertex_descriptor a2 = boost::add_vertex(g);
  Graph::vertex_descriptor a3 = boost::add_vertex(g);
  Graph::vertex_descriptor a4 = boost::add_vertex(g);
  Graph::vertex_descriptor a5 = boost::add_vertex(g);
  Graph::vertex_descriptor a6 = boost::add_vertex(g);
  Graph::vertex_descriptor a7 = boost::add_vertex(g);
 
  EdgeWeightProperty weight0 = 1;
  boost::add_edge(a1, a2, weight0, g); 
  EdgeWeightProperty weight1 = 1;
  boost::add_edge(a1, a3, weight1, g);
  EdgeWeightProperty weight2 = 1;
  boost::add_edge(a2, a3, weight2, g);
  EdgeWeightProperty weight3 = 1;
  boost::add_edge(a3, a4, weight3, g);
  EdgeWeightProperty weight4 = 1;
  boost::add_edge(a4, a5, weight4, g);
  EdgeWeightProperty weight5 = 1;
  boost::add_edge(a5, a6, weight5, g);
  EdgeWeightProperty weight6 = 1;
  boost::add_edge(a5, a7, weight6, g);
  EdgeWeightProperty weight7 = 1;
  boost::add_edge(a6, a7, weight7, g);
 
 
  typedef boost::property_map< Graph, boost::vertex_index_t>::type VertexIndexMap;
  VertexIndexMap v_index = get(boost::vertex_index, g);
  std::vector< double > v_centrality_vec(boost::num_vertices(g), 0.0);
  boost::iterator_property_map< std::vector< double >::iterator, VertexIndexMap >
          v_centrality_map(v_centrality_vec.begin(), v_index);
  brandes_betweenness_centrality( g, v_centrality_map);

}