From 1ff5a0c23538509db5aaa1977d3cf5b22a438a20 Mon Sep 17 00:00:00 2001 From: Saurav Bhattacharya Date: Mon, 2 Mar 2026 13:02:22 -0800 Subject: [PATCH] fix: label ensemble predictions as ENSEMBLE instead of COMMON_NEIGHBORS Add ENSEMBLE value to Method enum and use it in predictEnsemble() for both PredictedLink and PredictionResult construction. Previously, ensemble predictions were incorrectly tagged as COMMON_NEIGHBORS, making it impossible to distinguish them from actual common neighbor scores. Fixes #23 --- Gvisual/src/gvisual/LinkPredictionAnalyzer.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Gvisual/src/gvisual/LinkPredictionAnalyzer.java b/Gvisual/src/gvisual/LinkPredictionAnalyzer.java index 8d15473..e606ac0 100644 --- a/Gvisual/src/gvisual/LinkPredictionAnalyzer.java +++ b/Gvisual/src/gvisual/LinkPredictionAnalyzer.java @@ -56,7 +56,9 @@ public enum Method { /** Sum of 1/log(degree) for each common neighbor. */ ADAMIC_ADAR, /** Product of the two nodes' degrees. */ - PREFERENTIAL_ATTACHMENT + PREFERENTIAL_ATTACHMENT, + /** Weighted average across multiple prediction methods. */ + ENSEMBLE } // ── Result classes ────────────────────────────────────────── @@ -275,7 +277,7 @@ public PredictionResult predictEnsemble(int topK) { String[] verts = pairVertices.get(entry.getKey()); candidates.add(new PredictedLink(verts[0], verts[1], avg, - Method.COMMON_NEIGHBORS, pairCommon.get(entry.getKey()))); + Method.ENSEMBLE, pairCommon.get(entry.getKey()))); } Collections.sort(candidates, new Comparator() { @@ -289,7 +291,7 @@ public int compare(PredictedLink a, PredictedLink b) { 0, Math.min(topK, candidates.size())); return new PredictionResult(new ArrayList(top), - Method.COMMON_NEIGHBORS, n, existingEdges, possibleEdges, evaluated); + Method.ENSEMBLE, n, existingEdges, possibleEdges, evaluated); } // ── Scoring functions ───────────────────────────────────────