From 8075c97dd59fb393e3a17337dc3859da2b85d3a5 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Mon, 28 Apr 2025 14:07:36 +0200 Subject: add function solution() --- .../dk/biks/bachelorizer/Combi.java | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Combi.java b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Combi.java index 006d92a..4aec572 100644 --- a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Combi.java +++ b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Combi.java @@ -63,6 +63,9 @@ public final class Combi { // GraphAlgorithms.printGraph(g); GraphAlgorithms.printGraph(moduleGroups(nonOverlapping(g), g)); + System.out.println( + solution(moduleGroups(nonOverlapping(g), g))); + // release temporary variables for garbage collection _g = null; _vertice_count = null; @@ -206,4 +209,26 @@ System.out.println(" "+v.toString()); } return h; } + + /// groups of subject modules with no overlapping students + /// + /// @param g groups of non-overlapping selections as a graph + /// @return amount of students in consecutive slots + public static int solution(Graph g) { + + // pick a random vertice in the graph + Vertex v = g.vertices().iterator().next(); + + return solution(g, v); + } + + /// groups of subject modules with no overlapping students + /// + /// @param g groups of non-overlapping selections as a graph + /// @param v seed vertex within graph + /// @return amount of students in consecutive slots + public static int solution(Graph g, Vertex v) { + return GraphAlgorithms.pathLength( + GraphAlgorithms.dijkstra(g, v)); + } } -- cgit v1.2.3