optimizations for speed
separate out edges.py