Fixed bug in addEdge method. In case of undirected we need to check that the contact is inserted in the right order j>i