Implementing matrix_as_graph to convert a boost::numeric::ublas::matrix to a "graph"

Hi all, I wrote a small program in C++ using boost to read a neural network file (directional graph of a feedforward multilayer perceptron) into boost::numeric::ublas::matrix. The typical file size creates matrices of various sizes, anywhere from a 36x36 to a 130x130 matrix (of floats - edge weights between 0 and 1 to four sig figs). About half to two-thirds of the values are 0 in a typical graph, so I think of them as sparse. There are thousands of such files, so I have been really thrilled with the speed of boost. (I was doing this work with Perl last year. Ahem.) Now I want to implement the boost matrix_as_graph library so that I can convert my matrix into a graph and then implement various network metrics on the graph (such as betweenness_centrality.hpp). However, when I looked in the docs at http://www.boost.org/doc/libs/1_38_0/boost/graph/matrix_as_graph.hpp I was dismayed to find only a code listing: no explanation, no examples. I'm not the strongest C++ coder. Can someone point me to an example or tutorial of how to implement matrix_as_graph to turn a ublas::matrix into a graph? I think I could puzzle it out if I could find an example to emulate. I'll repay the community with a simple blog tutorial of how I did it, if someone can only help me get started. Thanks in advance, John -- John Burgoon Indiana University Bloomington, IN, USA --
Insight without implementation is worthless. Get to work.

AMDG John Burgoon wrote:
I wrote a small program in C++ using boost to read a neural network file (directional graph of a feedforward multilayer perceptron) into boost::numeric::ublas::matrix. The typical file size creates matrices of various sizes, anywhere from a 36x36 to a 130x130 matrix (of floats - edge weights between 0 and 1 to four sig figs). About half to two-thirds of the values are 0 in a typical graph, so I think of them as sparse. There are thousands of such files, so I have been really thrilled with the speed of boost. (I was doing this work with Perl last year. Ahem.)
Now I want to implement the boost matrix_as_graph library so that I can convert my matrix into a graph and then implement various network metrics on the graph (such as betweenness_centrality.hpp). However, when I looked in the docs at http://www.boost.org/doc/libs/1_38_0/boost/graph/matrix_as_graph.hpp I was dismayed to find only a code listing: no explanation, no examples.
I'm not the strongest C++ coder. Can someone point me to an example or tutorial of how to implement matrix_as_graph to turn a ublas::matrix into a graph? I think I could puzzle it out if I could find an example to emulate.
I'll repay the community with a simple blog tutorial of how I did it, if someone can only help me get started.
I don't know what matrix_as_graph is designed for, but it can't handle uBlas matrices. In Christ, Steven Watanabe
participants (2)
-
John Burgoon
-
Steven Watanabe