diff options
author | Jonas Smedegaard <dr@jones.dk> | 2025-04-28 23:23:58 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2025-04-28 23:23:58 +0200 |
commit | e54d71230df7f53bb1fa71e356a6c7dcca958b00 (patch) | |
tree | 1e670c36200a50ef569dd59f3f7128aa10ea8892 /src/dk.biks.bachelorizer/dk | |
parent | 32c0013bdf76240742dc3095447adaf5ccd29f8c (diff) |
rename class Combi -> Graph
Diffstat (limited to 'src/dk.biks.bachelorizer/dk')
-rw-r--r-- | src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java (renamed from src/dk.biks.bachelorizer/dk/biks/bachelorizer/Combi.java) | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Combi.java b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java index 6cde168..ed38f1d 100644 --- a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Combi.java +++ b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java @@ -14,33 +14,33 @@ import java.util.Set; import java.util.stream.Collectors; import com.example.portfolio3.AdjListGraph; -import com.example.portfolio3.Graph; +import com.example.portfolio3.AbstractGraph; import com.example.portfolio3.GraphAlgorithms; import com.example.portfolio3.MatrixGraph; import com.example.portfolio3.Vertex; -/// Combi - static sample dataset of course combinations +/// Bachelorizer - database model /// /// Slurps and parses data from upstream-provided comma-separated file. /// /// @version 0.0.1 /// @see <https://moodle.ruc.dk/mod/assign/view.php?id=523186> -public final class Combi { +public final class Graph { /// data about combinations as a Graph - private Graph g; + private AbstractGraph g; /// Default constructor /// /// @param path path to data file - private Combi(final String path) { + private Graph(final String path) { // read into temporary graph to resolve vertice count // // use Adjacency List Representation: // * cheap to bootstrap (done once) // * simple to count vertices (done once): O(1) - Graph _g = new AdjListGraph(); + AbstractGraph _g = new AdjListGraph(); GraphAlgorithms.readGraph(_g, path); Integer _vertice_count = _g.vertices().size(); @@ -52,7 +52,7 @@ public final class Combi { // * simple to get edges (done repeatedly): O(1) // // TODO: avoid reading and parsing file twice - Graph g = new MatrixGraph(_vertice_count); + AbstractGraph g = new MatrixGraph(_vertice_count); GraphAlgorithms.readGraph(g, path); System.out.println("\n\nGraph of choices constructed:"); @@ -78,7 +78,7 @@ public final class Combi { } // construct graph of disjoint choices - Graph h = moduleGroups(s, g); + AbstractGraph h = moduleGroups(s, g); System.out.println( "\n\nGraph of disjoint choices constructed:"); GraphAlgorithms.printGraph(h); @@ -105,7 +105,7 @@ public final class Combi { ? args[0] : "combi.txt"; - Combi combi = new Combi(path); + Graph combi = new Graph(path); } /// utility function to check that a graph is connected @@ -120,7 +120,7 @@ public final class Combi { /// @param g Graph to inspect /// @throws IllegalArgumentException /// https://docs.oracle.com/javase/tutorial/essential/exceptions/runtime.html - public static void assertConnected(Graph g) { + public static void assertConnected(AbstractGraph g) { // collect all vertices in the graph Collection<Vertex> c = g.vertices(); @@ -143,7 +143,7 @@ public final class Combi { /// /// @param g Graph to inspect /// @return list of disjoint sets - public static ArrayList<Set<Vertex>> disjoint(Graph g) { + public static ArrayList<Set<Vertex>> disjoint(AbstractGraph g) { // get all subject modules // @@ -159,7 +159,7 @@ public final class Combi { /// @param g Graph to inspect /// @param vip Ordered list of subject modules to prioritize /// @return List of sets of disjoint choices - public static ArrayList<Set<Vertex>> disjoint(Graph g, List<Vertex> vip) { + public static ArrayList<Set<Vertex>> disjoint(AbstractGraph g, List<Vertex> vip) { ArrayList<Set<Vertex>> sets = new ArrayList<>(); // track done subject modules as extendable set @@ -205,8 +205,8 @@ public final class Combi { /// @param sets list of disjoint choices /// @param g choices as weights in graph /// @return groups of disjoint choices as a graph - public static Graph moduleGroups(ArrayList<Set<Vertex>> sets, Graph g) { - Graph h = new AdjListGraph(); + public static AbstractGraph moduleGroups(ArrayList<Set<Vertex>> sets, AbstractGraph g) { + AbstractGraph h = new AdjListGraph(); for (Set<Vertex> s: sets) { for (Set<Vertex> t: sets) { if (t == s) continue; @@ -230,7 +230,7 @@ public final class Combi { /// /// @param g sets of disjoint choices as a graph /// @return amount of students in consecutive slots - public static int solution(Graph g) { + public static int solution(AbstractGraph g) { // pick a random vertice in the graph Vertex v = g.vertices().iterator().next(); @@ -243,7 +243,7 @@ public final class Combi { /// @param g groups of disjoint choices as a graph /// @param v seed vertex within graph /// @return amount of students in consecutive slots - public static int solution(Graph g, Vertex v) { + public static int solution(AbstractGraph g, Vertex v) { return GraphAlgorithms.pathLength( GraphAlgorithms.dijkstra(g, v)); } |