Skip to content

Commit

Permalink
loadash deepCopy
Browse files Browse the repository at this point in the history
  • Loading branch information
brunolnetto committed Jan 17, 2022
1 parent 4ad62c9 commit 4aecff7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/data-structures/graph/Graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,15 @@ export default class Graph {
* @returns {Graph} clone of this graph, but undirected
*/
retrieveUndirected(){
let undirected_graph = new Graph();
let edges = this.getAllEdges();

undirected_graph.addEdges(edges);
let undirected_graph = new Graph(false);
let edges_ = [];

for(let edge of this.getAllEdges()) {
edges_.push(_.cloneDeep(edge));
}

undirected_graph.addEdges(edges_);

return undirected_graph;
}

Expand Down

0 comments on commit 4aecff7

Please sign in to comment.