aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Valentin Christensen <valentianchristensen@gmail.com>2025-04-28 12:37:35 +0200
committerIan Valentin Christensen <valentianchristensen@gmail.com>2025-04-28 12:37:35 +0200
commitef733f6c0bb71befa419f60f10f1a20e5ac8c819 (patch)
treed67e09f7e02f50e208372471c100a90f75147f00
parent638a59aebae3e613c27833c1cb27c6724952a251 (diff)
add function moduleGroups
-rw-r--r--src/dk.biks.bachelorizer/dk/biks/bachelorizer/Combi.java21
1 files changed, 21 insertions, 0 deletions
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<Set<Vertex>> sets, Graph g) {
+ Graph h = new AdjListGraph();
+ for (Set<Vertex> s: sets) {
+ for (Set<Vertex> 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;
+ }
}