Some work on the graph building function