Use separate mechanisms to implement graph and tree creation, which speeds up graph creation by using a single map from location indices to graph nodes.