|BGL-Python bindings are no longer being maintained|
|While I've enjoyed working on and working with BGL-Python, I find that I no longer have time to maintain or support this library. If you are interested in working on BGL-Python further, please contact me. The Subversion version of BGL-Python is vastly improved over 0.9: I may still be able to compile one last releasse of this project.|
The Boost Graph Library Python bindings (which we refer to as "BGL-Python") expose the functionality of the Boost Graph Library and Parallel Boost Graph Library as a Python package, allowing one to perform computation-intensive tasks on graphs (or networks) from within an easy-to-use scripting language.
The goal of the BGL-Python bindings is to create a set of bindings for the majority of the BGL in Python that:
BGL-Python contains many of the data structures and algorithms found in the C++ (Parallel) Boost Graph Library, including:
The following simple program loads a GraphViz file, computes the minimum spanning tree of the graph, annotates the graph to illustrate the minimum spanning tree, and emits the result as a GraphViz file.
import boost.graph as bgl # Load a graph from the GraphViz file 'mst.dot' graph = bgl.Graph.read_graphviz('mst.dot') # Convert the weight into floating-point values weight = graph.convert_property_map(graph.edge_properties['weight'], 'float') # Compute the minimum spanning tree of the graph mst_edges = bgl.kruskal_minimum_spanning_tree(graph, weight) # Compute the weight of the minimum spanning tree print 'MST weight =',sum([weight[e] for e in mst_edges]) # Put the weights into the label. Make MST edges solid while all other # edges remain dashed. label = graph.edge_property_map('string') style = graph.edge_property_map('string') for e in graph.edges: label[e] = str(weight[e]) if e in mst_edges: style[e] = 'solid' else: style[e] = 'dashed' # Associate the label and style property maps with the graph for output graph.edge_properties['label'] = label graph.edge_properties['style'] = style # Write out the graph in GraphViz DOT format graph.write_graphviz('mst-out.dot')
There are several ways to get the BGL-Python bindings:
svn co https://svn.osl.iu.edu/svn/projects_viz/bgl-python
Douglas Gregor maintains the Python bindings for the Boost Graph
Library and Parallel Boost Graph Library. Questions may be sent
directly to Doug at or
posted to one of the Boost mailing
lists. Please put
[Graph] into the subject line of