From 48424d617a60b209218a98264859edc445af061d Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Tue, 29 Apr 2025 14:00:50 +0200 Subject: move comment above code --- .../dk/biks/bachelorizer/Graph.java | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java') diff --git a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java index ec4a35d..78ade2a 100644 --- a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java +++ b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java @@ -223,13 +223,19 @@ public final class Graph { AbstractGraph h = new AdjListGraph(); Map, String> groupLabel = new HashMap<>(); for (Set groupSet : sets) { - // create a string for each group of module selections + + // stringify each group of module selections String name = groupSet.stream() .map(Vertex::toString) - .sorted() // avoid differently sorted duplicates - .collect(Collectors.joining(", ", "{", "}")); + + // avoid differently sorted duplicates + .sorted() + // formatting of groups as vertices - groupLabel.put(groupSet, name); // map group to name of group + .collect(Collectors.joining(", ", "{", "}")); + + // map group to name of group + groupLabel.put(groupSet, name); } for (Set s: sets) { @@ -237,9 +243,13 @@ public final class Graph { if (t == s) { continue; } + + // process each pair only once if (s.hashCode() > t.hashCode()) { - continue; // process each pair no more than once + continue; } + + // accumulate student count across set int sum = 0; for (Vertex v: s) { // students with this choice -- cgit v1.2.3