Boost logo

Boost Users :

Subject: Re: [Boost-users] [graph] : newbie question on brandes_betweenness_centrality
From: Matthew Walker (matthew.walker.1_at_[hidden])
Date: 2009-09-21 12:12:31


Thank you very much for your help Andrew!  With your comments and a bit of trial-and-error, I found the following works:

  int lNumberOfVertices = num_vertices(g);

  typedef boost::exterior_vertex_property<Graph, float> BetweennessProperty;
  typedef BetweennessProperty::container_type Container;
  typedef BetweennessProperty::map_type Map;

  Container lCont(lNumberOfVertices, 0 );
  Map lMap(lCont, g);

  brandes_betweenness_centrality(g, lMap);
  double lCentralization = central_point_dominance(g, lMap);
  double lScaler = 2.0/(lNumberOfVertices*lNumberOfVertices - 3*lNumberOfVertices +2);
  lCentralization *= lScaler;


Cheers again,

Matthew

Andrew Sutton wrote:

  ... // I am reading a network from a file and storing it into lEdges and lNumVertices
 typedef adjacency_list<vecS, vecS, undirectedS  > Graph;
 Graph g(lEdges.begin(), lEdges.end(), lNumVertices);

 typedef boost::exterior_vertex_property<Graph, float> BetweennessProperty;
 typedef BetweennessProperty::map_type BetweennessMap;

 BetweennessMap lMap;
 brandes_betweenness_centrality(g, lMap);
}

If I could get this to work, I then have aspirations that the helper function central_point_dominance(g, lMap) might give me the betweenness centralization measure that I'm after.

Thanks in advance for your help!

I would consider steering clear of the exterior_vertex_property template for now. I haven't had a chance to fully document it and it may change in future releases. It is very much an undocumented feature.

The lack of documentation is causing your problem. An exterior property requires two components: a container, which associates data with vertices and edges, and the property map, which abstracts the association into something usable in a generic manner. Your property map is not actually bound to a container (perpahps the default constructor should be private). I think, what you really want to write is:

typedef BetProperty::container_type Container;
t4ypedef BetProperty::map_type Map;

Container cont(g, /* default value */ );
Map map(cont);

The container is constructed over the graph, assigning a default value to each vertex. The map is bound to the container.
 
Andrew Sutton
andrew.n.sutton@gmail.com

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