public Edge addUndirectionalEdge(Edge e) { Vertex origin = e.getOrigin(); Vertex destination = e.getDestination(); origin.addOutEdge(e); destination.addOutEdge(e); origin.addInEdge(e); destination.addInEdge(e); //Add, if missing vertices if (!vertices.ContainsKey(origin.getId())) { vertices.Add(origin.getId(), origin); } if (!vertices.ContainsKey(destination.getId())) { vertices.Add(destination.getId(), destination); } if (!edges.Contains(e)) { edges.Add(e); } return(e); }