fix concurrent modification bug
This commit is contained in:
@@ -9,15 +9,17 @@ public interface GraphModificationFunctions {
|
|||||||
static Map<DefaultWeightedEdge, Vertex[]> filterByOverlapThresholds(SimpleWeightedGraph<Vertex, DefaultWeightedEdge> graph,
|
static Map<DefaultWeightedEdge, Vertex[]> filterByOverlapThresholds(SimpleWeightedGraph<Vertex, DefaultWeightedEdge> graph,
|
||||||
int low, int high, boolean saveEdges) {
|
int low, int high, boolean saveEdges) {
|
||||||
Map<DefaultWeightedEdge, Vertex[]> removedEdges = new HashMap<>();
|
Map<DefaultWeightedEdge, Vertex[]> removedEdges = new HashMap<>();
|
||||||
|
Set<DefaultWeightedEdge> edgesToRemove = new HashSet<>();
|
||||||
for (DefaultWeightedEdge e : graph.edgeSet()) {
|
for (DefaultWeightedEdge e : graph.edgeSet()) {
|
||||||
if ((graph.getEdgeWeight(e) > high) || (graph.getEdgeWeight(e) < low)) {
|
if ((graph.getEdgeWeight(e) > high) || (graph.getEdgeWeight(e) < low)) {
|
||||||
if(saveEdges) {
|
if(saveEdges) {
|
||||||
Vertex[] vertices = {graph.getEdgeSource(e), graph.getEdgeTarget(e)};
|
Vertex[] vertices = {graph.getEdgeSource(e), graph.getEdgeTarget(e)};
|
||||||
removedEdges.put(e, vertices);
|
removedEdges.put(e, vertices);
|
||||||
}
|
}
|
||||||
graph.removeEdge(e);
|
edgesToRemove.add(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
edgesToRemove.forEach(graph::removeEdge);
|
||||||
return removedEdges;
|
return removedEdges;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,6 +27,7 @@ public interface GraphModificationFunctions {
|
|||||||
static Map<DefaultWeightedEdge, Vertex[]> filterByRelativeOccupancy(SimpleWeightedGraph<Vertex, DefaultWeightedEdge> graph,
|
static Map<DefaultWeightedEdge, Vertex[]> filterByRelativeOccupancy(SimpleWeightedGraph<Vertex, DefaultWeightedEdge> graph,
|
||||||
Integer maxOccupancyDifference, boolean saveEdges) {
|
Integer maxOccupancyDifference, boolean saveEdges) {
|
||||||
Map<DefaultWeightedEdge, Vertex[]> removedEdges = new HashMap<>();
|
Map<DefaultWeightedEdge, Vertex[]> removedEdges = new HashMap<>();
|
||||||
|
Set<DefaultWeightedEdge> edgesToRemove = new HashSet<>();
|
||||||
for (DefaultWeightedEdge e : graph.edgeSet()) {
|
for (DefaultWeightedEdge e : graph.edgeSet()) {
|
||||||
Integer alphaOcc = graph.getEdgeSource(e).getOccupancy();
|
Integer alphaOcc = graph.getEdgeSource(e).getOccupancy();
|
||||||
Integer betaOcc = graph.getEdgeTarget(e).getOccupancy();
|
Integer betaOcc = graph.getEdgeTarget(e).getOccupancy();
|
||||||
@@ -33,9 +36,10 @@ public interface GraphModificationFunctions {
|
|||||||
Vertex[] vertices = {graph.getEdgeSource(e), graph.getEdgeTarget(e)};
|
Vertex[] vertices = {graph.getEdgeSource(e), graph.getEdgeTarget(e)};
|
||||||
removedEdges.put(e, vertices);
|
removedEdges.put(e, vertices);
|
||||||
}
|
}
|
||||||
graph.removeEdge(e);
|
edgesToRemove.add(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
edgesToRemove.forEach(graph::removeEdge);
|
||||||
return removedEdges;
|
return removedEdges;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,6 +48,7 @@ public interface GraphModificationFunctions {
|
|||||||
Integer minOverlapPercent,
|
Integer minOverlapPercent,
|
||||||
boolean saveEdges) {
|
boolean saveEdges) {
|
||||||
Map<DefaultWeightedEdge, Vertex[]> removedEdges = new HashMap<>();
|
Map<DefaultWeightedEdge, Vertex[]> removedEdges = new HashMap<>();
|
||||||
|
Set<DefaultWeightedEdge> edgesToRemove = new HashSet<>();
|
||||||
for (DefaultWeightedEdge e : graph.edgeSet()) {
|
for (DefaultWeightedEdge e : graph.edgeSet()) {
|
||||||
Integer alphaOcc = graph.getEdgeSource(e).getOccupancy();
|
Integer alphaOcc = graph.getEdgeSource(e).getOccupancy();
|
||||||
Integer betaOcc = graph.getEdgeTarget(e).getOccupancy();
|
Integer betaOcc = graph.getEdgeTarget(e).getOccupancy();
|
||||||
@@ -54,9 +59,10 @@ public interface GraphModificationFunctions {
|
|||||||
Vertex[] vertices = {graph.getEdgeSource(e), graph.getEdgeTarget(e)};
|
Vertex[] vertices = {graph.getEdgeSource(e), graph.getEdgeTarget(e)};
|
||||||
removedEdges.put(e, vertices);
|
removedEdges.put(e, vertices);
|
||||||
}
|
}
|
||||||
graph.removeEdge(e);
|
edgesToRemove.add(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
edgesToRemove.forEach(graph::removeEdge);
|
||||||
return removedEdges;
|
return removedEdges;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user