Even more efficient graph creation (my initial scheme, but this time without accidentally changing what's in the sequence records)

This commit is contained in:
eugenefischer
2025-04-10 15:03:10 -05:00
parent 187401f2d6
commit d1810c453d

View File

@@ -150,36 +150,20 @@ public class Simulator implements GraphModificationFunctions {
//add edges //add edges
for(Vertex a: alphaVertices) { for(Vertex a: alphaVertices) {
for(Vertex b: betaVertices) { for(Vertex b: betaVertices) {
double weight = 0.0; Set<Integer> sharedWells = new HashSet<>(a.getRecord().getWells());
for (Integer well: a.getRecord().getWells()) { sharedWells.retainAll(b.getRecord().getWells());
if (b.getRecord().isInWell(well)) { double weight = (double) sharedWells.size();
weight += 1.0;
}
}
if (weight != 0.0) { if (weight != 0.0) {
System.out.println("Edge weight: " + weight);
DefaultWeightedEdge edge = graph.addEdge(a, b); DefaultWeightedEdge edge = graph.addEdge(a, b);
graph.setEdgeWeight(edge, weight); graph.setEdgeWeight(edge, weight);
} }
else {
System.out.println("No overlap");
}
} }
} }
// //add edges
// for(Vertex a: alphaVertices) {
// for(Integer well: a.getRecord().getWells()) {
// for (Vertex b: betaVertices) {
// if (b.getRecord().isInWell(well)) {
// DefaultWeightedEdge edge = graph.getEdge(a, b);
// if (edge == null) {
// edge = graph.addEdge(a, b);
// graph.setEdgeWeight(edge, 1.0);
// }
// else {
// double weight = graph.getEdgeWeight(edge);
// graph.setEdgeWeight(edge, weight + 1.0);
// }
// }
// }
// }
// }
if(verbose){System.out.println("Graph created");} if(verbose){System.out.println("Graph created");}
//stop timing //stop timing
Instant stop = Instant.now(); Instant stop = Instant.now();