aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java (renamed from src/dk.biks.bachelorizer/dk/biks/bachelorizer/Combi.java)32
2 files changed, 17 insertions, 17 deletions
diff --git a/Makefile b/Makefile
index 17d5676..e29aeb4 100644
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,7 @@ JAVA_EXTRACLASSES_portfolio3 = AbstractGraph AdjListGraph AdjMapGraph \
Edge EdgeGraph GraphAlgorithms Graph Graphs MatrixGraph Vertex
JAVA_MODULEPATHS_bachelorizer = /usr/share/openjfx/lib
JAVA_ROOT_bachelorizer = src/dk.biks.bachelorizer
-JAVA_MAINCLASSES_bachelorizer = Main Combi Window
+JAVA_MAINCLASSES_bachelorizer = Main Graph Window
JAVA_EXTRACLASSES_bachelorizer = Control GUI Person
JAVA_MODULES_bachelorizer = $(addprefix javafx.,base controls graphics)
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));
}