aboutsummaryrefslogtreecommitdiff
path: root/src/dk.biks.bachelorizer/dk/biks/bachelorizer
diff options
context:
space:
mode:
authorIan Valentin Christensen <valentianchristensen@gmail.com>2025-04-29 15:20:57 +0200
committerIan Valentin Christensen <valentianchristensen@gmail.com>2025-04-29 15:20:57 +0200
commit9e342ef95d18611e3f85f503ea1f003b896fe712 (patch)
treedd3b59aee04ff1d871776f99baa99816070e43d0 /src/dk.biks.bachelorizer/dk/biks/bachelorizer
parentc5efbd6ce076ee0dfaf507ce5bc6aa79c8872432 (diff)
make nice little comments and javadoc
Diffstat (limited to 'src/dk.biks.bachelorizer/dk/biks/bachelorizer')
-rw-r--r--src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java
index 487e4bf..d052258 100644
--- a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java
+++ b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java
@@ -277,33 +277,36 @@ public final class Graph {
return h;
}
- /// groups of disjoint module choices
+ /// loop through random combinations of sets of modules
///
/// @param g sets of disjoint choices as a graph
- /// @return amount of students in consecutive slots
+ /// @return best path out of a hundred shuffles
public static int goodSolution(final AbstractGraph g) {
- int bestPathCost = Integer.MAX_VALUE; // number higher than total students
- for (int i = 0; i < 100; i++) {
+ // number higher than total students
+ int bestPathCost = Integer.MAX_VALUE;
+ for (int i = 0; i < 10000; i++) {
int cost = solution(g);
if (cost < bestPathCost) {
+ // store shortest path
bestPathCost = cost;
}
}
return bestPathCost;
}
+ /// finds lengh of random path through disjoint module choices
+ ///
+ /// @param g sets of disjoint choices as a graph
+ /// @return weight of final random path
private static int solution(final AbstractGraph g) {
List<Vertex> path = new ArrayList<>(g.vertices());
- Collections.shuffle(path); // order represents path
+ // order of list contents becomes path order
+ Collections.shuffle(path);
int cost = 0;
for (int i = 0; i < path.size() - 1; i++) {
+ // get weight between next vertices in module group graph
cost += g.getWeight(path.get(i), path.get(i + 1));
}
return cost;
}
- /// groups of disjoint module choices seeded by start vertex
- ///
- /// @param g groups of disjoint choices as a graph
- /// @param v seed vertex within graph
- /// @return amount of students in consecutive slots
}