08/14/2011 update: C++ codes to implement Boost Graph Library (BGL) routines uploaded. As of current date, the BGL routines presented here are used to check adjacency, distance, and path matrices, and betweenness centrality.
Important details:
bgl.plugin is compiled using g++ in Unix.
Separate compilation is necessary for other platforms (e.g. Windows, Mac).
Stata's st_plugin() is used to attach the plugin (compiled C++ routines) to Stata.
Latest version of BGL can be accessed through the main Boost Library website.
Compilation details (using g++ in Unix - command may vary for other compilers/platforms):
$ g++ -shared -DSYSTEM=OPUNIX -I/<path>/boost_1_47_0 stplugin.c bgl.cpp -o bgl.plugin -fPIC
Note: Don't type the first "$" character - it's a standard way to denote command lines.
Compilation option details:
"-I" is a way to specify a search path (in this case where BGL source codes are located).
"<path>" is the path to where you've saved the Boost package.
bgl.cpp is the C++ code to be compiled.
bgl.plugin is the output compilation file.
-fPIC is something that I was prompted to specify for g++ to work correctly on my machine (otherwise without -fPIC I would error out).
Other options (e.g. -shared, -DSYSTEM=OPUNIX) are specified following st_plugin().
Files included in attachment:
stplugin.h: Stata header file.
path_matrix.h: Customized header file for computing path matrix and betweenness centrality.
stplugin.c: Stata program for plugin.
bgl.cpp: C++ program to compute various network measures.
bgl.plugin: Compiled code for use in Unix systems.
Required BGL plugin parameters:
scalar directed=0|1: Specify whether network is directed (scalar directed=1) or undirected (scalar directed=0).
scalar infinity=real: Specify a real number to replace missing entries in computed distance matrix.
local binary_filename filename: Specify output file name for matrices and vectors stored as binary data.
Note: When calculating the path matrix, the BGL plugin always creates an external binary file named "path_matrix" (no extension) for internal data transfer purposes in current working directory.
local measure network_measure: Specify either adjacency, distance, path, or betweenness.
local statistic mata_function: Specify a Mata function presented in Stata implementation (2): postcomputation command with the exception of any functions that calculate the mean.
Syntax:
program bgl, plugin (required to load plugin into memory).
plugin call bgl source_varname target_varname weightvar bgl_source_varname bgl_target_varname [if] [in]
Remarks:
source_varname target_varname weightvar bgl_source_varname bgl_target_varname all must exist as Stata variables before calling plugin.
If network is unweighted, specify a variable equal to all ones as weightvar.
Network measure is returned in bgl_source_varname bgl_target_varname. Generate these two variables before calling plugin as missing numeric variables. Subsequent calls to plugin will write over anything stored in the two variables without warning.