From ef733f6c0bb71befa419f60f10f1a20e5ac8c819 Mon Sep 17 00:00:00 2001 From: Ian Valentin Christensen Date: Mon, 28 Apr 2025 12:37:35 +0200 Subject: add function moduleGroups --- .../dk/biks/bachelorizer/Combi.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Combi.java b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Combi.java index 0db2169..da28d5c 100644 --- a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Combi.java +++ b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Combi.java @@ -61,6 +61,7 @@ public final class Combi { nonOverlapping(g); // GraphAlgorithms.printGraph(g); + GraphAlgorithms.printGraph(moduleGroups(nonOverlapping(g), g)); // release temporary variables for garbage collection _g = null; @@ -179,4 +180,24 @@ System.out.println(" "+v.toString()); return sets; } + public static Graph moduleGroups(ArrayList> sets, Graph g) { + Graph h = new AdjListGraph(); + for (Set s: sets) { + for (Set t: sets) { + if (t == s) continue; + int sum = 0; + for (Vertex v: s) { + // get num of students with this combination of modules. + for (Vertex w: t) { + Integer weight = g.getWeight(v, w); + if (weight != null) { + sum += weight; + } + } + } + h.insertEdge(s.toString(), t.toString(), sum); + } + } + return h; + } } -- cgit v1.2.3