-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCourseNode.java
76 lines (63 loc) · 2.13 KB
/
CourseNode.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import java.util.ArrayList;
public class CourseNode {
// course id for each node
private String courseID;
// how many students are enrolled in particular course
private int enrollment;
// allocated time slot serial number
private int allocation;
// adjacency list of the graph nodes, overlapping/clashing courses having common students
private ArrayList<CourseNode> adjacentCourses;
private int dfsState; // 0 => not visited (white), 1 => in stack (gray), 2 => visited (black)
public CourseNode(String id, int students){
this.courseID = id;
this.enrollment = students;
this.allocation = -1; // invalid graph coloring by default
this.adjacentCourses = new ArrayList<>();
}
public String getCourseID() {
return courseID;
}
public void setCourseID(String courseID) {
this.courseID = courseID;
}
public int getDfsState() {
return dfsState;
}
public void setDfsState(int dfsState) {
this.dfsState = dfsState;
}
public int getEnrollment() {
return enrollment;
}
public void setEnrollment(int enrollment) {
this.enrollment = enrollment;
}
public int getAllocation() {
return allocation;
}
public void setAllocation(int allocation) {
this.allocation = allocation;
}
public CourseNode[] getAdjacentCourses() {
CourseNode[] courses = new CourseNode[adjacentCourses.size()];
for(int i=0; i<courses.length; i++){
courses[i] = adjacentCourses.get(i);
}
return courses;
}
public void setAdjacentCourses(ArrayList<CourseNode> adjacentCourses) {
this.adjacentCourses = adjacentCourses;
}
public void addEdges(CourseNode c){
this.adjacentCourses.add(c);
}
@Override
public String toString() {
return "CourseNode{" +
"courseID='" + courseID + '\'' +
", enrollment=" + enrollment + '\'' +
", conflicts=" + adjacentCourses.size() +
'}';
}
}