Implementing the graph builder