Skip to content

Commit

Permalink
fixes #3272 - copy of graph now copy also the weights
Browse files Browse the repository at this point in the history
  • Loading branch information
ptaillandier committed Jan 4, 2022
1 parent 6848b16 commit 22dbbd4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Expand Up @@ -187,7 +187,7 @@ public GamaSpatialGraph(final IContainer edges, final IContainer vertices, final
public GamaSpatialGraph(final IScope scope, final IType nodeType, final IType edgeType) {
super(scope, nodeType, edgeType);
verticesBuilt = new HashMap();
}
}

@Override
public GamaSpatialGraph copy(final IScope scope) {
Expand All @@ -196,6 +196,12 @@ public GamaSpatialGraph copy(final IScope scope) {

Graphs.addAllVertices(g, this.getVertices());
Graphs.addAllEdges(g, this, this.edgeSet());
for(Object obj : getVertices()) {
g.setVertexWeight(obj, getWeightOf(obj));
}
for(Object obj : getEdges()) {
g.setEdgeWeight(obj, getWeightOf(obj));
}
return g;
}

Expand Down
6 changes: 6 additions & 0 deletions msi.gama.core/src/msi/gama/util/graph/GamaGraph.java
Expand Up @@ -1481,6 +1481,12 @@ public IGraph copy(final IScope scope) {

Graphs.addAllVertices(g, this.getVertices());
Graphs.addAllEdges(g, this, this.edgeSet());
for(Object obj : getVertices()) {
g.setVertexWeight(obj, getWeightOf(obj));
}
for(Object obj : getEdges()) {
g.setEdgeWeight(obj, getWeightOf(obj));
}
return g;
}

Expand Down

0 comments on commit 22dbbd4

Please sign in to comment.