diff options
author | Jonas Smedegaard <dr@jones.dk> | 2025-04-28 14:07:36 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2025-04-28 14:07:36 +0200 |
commit | 8075c97dd59fb393e3a17337dc3859da2b85d3a5 (patch) | |
tree | b45f15b3a4ca0c6bd9ee5e2cbaedbf219c2ddbcb | |
parent | ea34b0f620c45623203cc302cd29dd81246a088a (diff) |
add function solution()
-rw-r--r-- | src/dk.biks.bachelorizer/dk/biks/bachelorizer/Combi.java | 25 |
1 files changed, 25 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 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)); + } } |