phishman3579/java-algorithms-implementation

Possible bug in Graph definition

liuzhilide opened this issue · 1 comments

/** Deep copies **/
public Graph(Graph<T> g) {
    type = g.getType();

    // Copy the vertices which also copies the edges
    for (Vertex<T> v : g.getVertices())
        this.allVertices.add(new Vertex<T>(v));

    for (Vertex<T> v : this.getVertices()) {
        for (Edge<T> e : v.getEdges()) {
            this.allEdges.add(e);
        }
    }
}

I don't think it‘s a Deep copies. Although those new Vertices have associated with those Edges, but Edges still associated with old Vertices;

Did you solve the deep copy?