Remove networkx dependency

topo.py makes light use of a single class in the very heavy-weight networkx module. Both networkx and it's transitive dependencies can be factored out by implementing a small Graph class.