Re-org with some common graph stuff moved to graph.py