Implemented the addEdge method.