Introduce graph mutations

This is a work in progress. It's shaping up to be a massive overhaul, but I think it's for the best.