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

Commit 9f221e0

Browse files
author
Repo Gardener
committed
code: clean up javac -Xlint warnings (unchecked, serial, redundant cast)
- TournamentAnalyzer.slaterExact: replace the generic-array sentinel `List<String>[] bestOrder = new List[]{...}` (which forced an `[unchecked] unchecked conversion` warning and the only suppression- free generic-array allocation in the file) with a type-safe single-element `List<List<String>>`. Same algorithm, same mutation semantics through the branch-and-bound recursion, zero warnings. - GraphInfluenceSeedAdvisor.synthesize: drop two `(double)` casts on values that are already declared `double` (`expectedCoverage` and `baseline`). Flagged by `-Xlint:cast` as redundant. - Add `serialVersionUID = 1L` to four Swing classes that extend `JComponent`/`JFrame`/`JDialog` (AdjacencyMatrixHeatmap, Main, StatsPanel, RandomGraphDialog). These are `Serializable` by inheritance and were each emitting `[serial] no definition of serialVersionUID`; the JDK uses an implementation-specific hash when the field is missing, so any future field reorder silently breaks deserialization. Verification: `mvn clean compile` is clean of the targeted warnings (unchecked / cast / serial). `mvn test` for the touched classes: TournamentAnalyzerTest 76/76 pass, GraphInfluenceSeedAdvisorTest 14/14 pass. Full `mvn test` shows the same 27 failures + 8 errors as on origin/master (LinkPredictionAnalyzerTest, GraphLabelingAnalyzerTest, etc.) — pre-existing, unrelated to this change.
1 parent f5bd6ef commit 9f221e0

6 files changed

Lines changed: 16 additions & 7 deletions

File tree

Gvisual/src/gvisual/AdjacencyMatrixHeatmap.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
*/
2727
public class AdjacencyMatrixHeatmap extends JPanel {
2828

29+
private static final long serialVersionUID = 1L;
30+
2931
private final Graph<String, Edge> graph;
3032
private List<String> nodeOrder;
3133
private final Map<String, Map<String, Edge>> adjacency;

Gvisual/src/gvisual/GraphInfluenceSeedAdvisor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,12 +428,12 @@ public int compare(Integer a, Integer b) {
428428
double reductionFraction = 0.0;
429429
if (mode == Mode.SPREAD) {
430430
expectedCoverage = finalDecisions.isEmpty() ? 0.0 : finalDecisions.get(finalDecisions.size() - 1).coverageEstimate;
431-
coverageFraction = (double) expectedCoverage / n;
431+
coverageFraction = expectedCoverage / n;
432432
} else {
433433
double remaining = finalDecisions.isEmpty() ? baseline : finalDecisions.get(finalDecisions.size() - 1).coverageEstimate;
434434
expectedCoverage = remaining;
435435
expectedReduction = baseline - remaining;
436-
coverageFraction = (double) baseline / n;
436+
coverageFraction = baseline / n;
437437
reductionFraction = baseline > 0 ? expectedReduction / baseline : 0.0;
438438
}
439439

Gvisual/src/gvisual/Main.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
*/
7676
public class Main extends JFrame {
7777

78+
private static final long serialVersionUID = 1L;
79+
7880
private static final Logger LOGGER = Logger.getLogger(Main.class.getName());
7981
private static final Color DEFAULT_BG_COLOR = Color.BLACK;
8082
private static final Color Vertex_COLOR = Color.WHITE;

Gvisual/src/gvisual/RandomGraphDialog.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
*/
2929
public class RandomGraphDialog extends JDialog {
3030

31+
private static final long serialVersionUID = 1L;
32+
3133
private Graph<String, Edge> generatedGraph = null;
3234

3335
private final JComboBox<String> modelCombo;

Gvisual/src/gvisual/StatsPanel.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
public class StatsPanel extends JPanel {
1717

18+
private static final long serialVersionUID = 1L;
19+
1820
private static final Font LABEL_FONT = new Font("SansSerif", Font.PLAIN, 12);
1921

2022
private final JLabel statsNodeCount;

Gvisual/src/gvisual/TournamentAnalyzer.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -788,13 +788,14 @@ private SlaterResult slaterExact(List<RankEntry> copeland) {
788788
// Use greedy result as initial upper bound for pruning
789789
SlaterResult greedy = slaterGreedy(copeland);
790790
int[] bestDisagreements = {greedy.getDisagreements()};
791-
List<String>[] bestOrder = new List[]{new ArrayList<>(greedy.getRanking())};
791+
List<List<String>> bestOrder = new ArrayList<>(1);
792+
bestOrder.add(new ArrayList<>(greedy.getRanking()));
792793

793794
boolean[] used = new boolean[n];
794795
List<String> current = new ArrayList<>(n);
795796

796797
slaterBranchAndBound(current, used, 0, bestDisagreements, bestOrder);
797-
return new SlaterResult(bestOrder[0], bestDisagreements[0]);
798+
return new SlaterResult(bestOrder.get(0), bestDisagreements[0]);
798799
}
799800

800801
/**
@@ -806,18 +807,18 @@ private SlaterResult slaterExact(List<RankEntry> copeland) {
806807
* @param used which vertex indices are already placed
807808
* @param partialDis disagreements accumulated in the partial ordering
808809
* @param bestDis single-element array holding the best disagreement count
809-
* @param bestOrder single-element array holding the best ordering found
810+
* @param bestOrder single-element list holding the best ordering found
810811
*/
811812
private void slaterBranchAndBound(List<String> current, boolean[] used,
812813
int partialDis, int[] bestDis,
813-
List<String>[] bestOrder) {
814+
List<List<String>> bestOrder) {
814815
int pos = current.size();
815816
int n = vertices.size();
816817

817818
if (pos == n) {
818819
if (partialDis < bestDis[0]) {
819820
bestDis[0] = partialDis;
820-
bestOrder[0] = new ArrayList<>(current);
821+
bestOrder.set(0, new ArrayList<>(current));
821822
}
822823
return;
823824
}

0 commit comments

Comments
 (0)