pull the graph code out to separate files