refactored data structure for logical manner
distinguishing between edges and nodes
changed data structure