Monthly Archives: May 2016

My Experiments with Boost Graph Library

Recently I picked up “An Introduction to Graph Theory” by Robin J. Wilson. After going through a couple of chapters I felt the sudden urge to try out a few of graph theory problems through programming. To try out the algorithms I first need to create the graphs themselves, which seemed a bit of a tedious task. But then thats what the boost graph Library is there for.

The BGL has made it very easy to create graphs and perform any operations on them.

Below is a simple program that lets you create a graph using the BGL.


int main(){
 boost::adjacency_list<> graph;
 int noVert = 0;
 int start=0,end=0;
 char choice = 'y';

 while(choice == 'y') {
 std::cout<<"Enter the start and end vertex of the edge: ";
 std::cout<<"Do you want to add another edge(y/n): ";

 return 0;

The coolest feature of BGL is that it allows you to write your graph as ‘dot’ file, which can be used to by Graphviz to visualize. Checkout my github repo for more BGL based programs.

%d bloggers like this: