Skip to content
This repository was archived by the owner on Jun 18, 2026. It is now read-only.

Commit 4e3c5de

Browse files
fix: vaccination edge count double-counting + Main.java compile error
Bug 1 — findVaccinationTargets() double-counted shared edges: The old implementation summed the degrees of all vaccination targets to compute totalEdgesBlocked. When two adjacent targets shared an edge, that edge was counted twice — causing edgesBlocked to exceed the actual number of edges and coverageRatio to exceed 100%. Example: Star graph A-B, A-C, A-D, A-E (4 edges). Vaccinating {A (deg=4), B (deg=1)}: old code reported 5 edges blocked out of 4 total (125% coverage). Fix: Count distinct edges where at least one endpoint is a target. Uses graph.getEndpoints() for robustness. Now correctly reports 4/4 (100% coverage) for the same scenario. Bug 2 — Main.java extra closing brace from refactor commit: The CategoryRow refactor (45e03d8) left an extra closing brace after initializeCategoryPanel(), causing all subsequent methods (initializeToolBar, copyfile, main) to fall outside the class body. This broke compilation entirely (14 'class, interface, or enum expected' errors).
1 parent 6eeab81 commit 4e3c5de

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

Gvisual/src/gvisual/InfluenceSpreadSimulator.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,28 @@ public VaccinationStrategy findVaccinationTargets(int k) {
357357
degrees.sort((a, b) -> Integer.compare(b.getValue(), a.getValue()));
358358

359359
List<String> targets = new ArrayList<>();
360-
int totalEdgesBlocked = 0;
360+
Set<String> targetSet = new HashSet<>();
361361
for (int i = 0; i < Math.min(k, degrees.size()); i++) {
362362
targets.add(degrees.get(i).getKey());
363-
totalEdgesBlocked += degrees.get(i).getValue();
363+
targetSet.add(degrees.get(i).getKey());
364+
}
365+
366+
// Count distinct edges blocked: an edge is blocked if at least one
367+
// of its endpoints is a vaccination target. Counting by degree
368+
// double-counts edges where both endpoints are vaccinated.
369+
int totalEdgesBlocked = 0;
370+
for (edge e : graph.getEdges()) {
371+
Collection<String> endpoints = graph.getEndpoints(e);
372+
boolean blocked = false;
373+
for (String ep : endpoints) {
374+
if (targetSet.contains(ep)) {
375+
blocked = true;
376+
break;
377+
}
378+
}
379+
if (blocked) {
380+
totalEdgesBlocked++;
381+
}
364382
}
365383

366384
int totalEdges = graph.getEdgeCount();

Gvisual/src/gvisual/Main.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2308,7 +2308,6 @@ public final void initializeCategoryPanel() {
23082308
sgShowParam = categoryRows[4].settingsButton;
23092309
sgHpanel = categoryRows[4].headerPanel;
23102310
}
2311-
}
23122311

23132312
/**
23142313
* initialize the toolbar

0 commit comments

Comments
 (0)