replaced list of edges with a dict. did not help performance much though.