java-algorithms-implementation icon indicating copy to clipboard operation
java-algorithms-implementation copied to clipboard

Possible bug in Graph definition

Open liuzhilide opened this issue 6 years ago • 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;

liuzhilide avatar Aug 21 '18 10:08 liuzhilide

Did you solve the deep copy?

Ikhideifidon avatar Aug 28 '22 02:08 Ikhideifidon