Sim refactor

A bit of refactoring in `simulator.py`, including the addition of a graph module that lets us drop the NetworkX dependency. Contains an improved version of #299.