refactored edges, implemented triangle counting