store edges by pointer rather then index