c++ implementation of blockgraph